Prechádzať zdrojové kódy

x/build/blob: cover Complete

Blake Mizerany 1 rok pred
rodič
commit
31e9b3dd15
1 zmenil súbory, kde vykonal 28 pridanie a 0 odobranie
  1. 28 0
      x/build/blob/ref_test.go

+ 28 - 0
x/build/blob/ref_test.go

@@ -69,6 +69,34 @@ func TestParseRef(t *testing.T) {
 	}
 }
 
+func TestRefComplete(t *testing.T) {
+	cases := []struct {
+		in   string
+		want bool
+	}{
+		{"", false},
+		{"example.com/mistral:7b+x", false},
+		{"example.com/mistral:7b+Q4_0", false},
+		{"example.com/x/mistral:latest", false},
+		{"mistral:7b+x", false},
+
+		{"example.com/x/mistral:latest+Q4_0", true},
+	}
+
+	for _, tt := range cases {
+		t.Run(tt.in, func(t *testing.T) {
+			ref := ParseRef(tt.in)
+			t.Logf("ParseRef(%q) = %#v", tt.in, ref)
+			if g := ref.Complete(); g != tt.want {
+				t.Errorf("Complete(%q) = %v; want %v", tt.in, g, tt.want)
+			}
+			if ref.Complete() != Complete(tt.in) {
+				t.Errorf("ParseRef(%s).Complete() != Complete(%s)", tt.in, tt.in)
+			}
+		})
+	}
+}
+
 func TestRefFull(t *testing.T) {
 	const empty = "!(MISSING DOMAIN)/!(MISSING NAMESPACE)/!(MISSING NAME):!(MISSING TAG)+!(MISSING BUILD)"