Explorar o código

x/build/blob: cover Complete

Blake Mizerany hai 1 ano
pai
achega
31e9b3dd15
Modificáronse 1 ficheiros con 28 adicións e 0 borrados
  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)"