diff --git a/x/model/name.go b/x/model/name.go index 8df81b5f..fa6c7192 100644 --- a/x/model/name.go +++ b/x/model/name.go @@ -286,6 +286,12 @@ func (r Name) Complete() bool { return !slices.Contains(r.Parts(), "") } +// CompleteNoBuild reports whether the Name is fully qualified without the +// build part. +func (r Name) CompleteNoBuild() bool { + return !slices.Contains(r.Parts()[:4], "") +} + // EqualFold reports whether r and o are equivalent model names, ignoring // case. func (r Name) EqualFold(o Name) bool { diff --git a/x/model/name_test.go b/x/model/name_test.go index 47dfd987..8898c5f9 100644 --- a/x/model/name_test.go +++ b/x/model/name_test.go @@ -138,11 +138,11 @@ func TestParseName(t *testing.T) { } } -func TestComplete(t *testing.T) { +func TestCompleteWithAndWithoutBuild(t *testing.T) { cases := []struct { - in string - complete bool - completeWithoutBuild bool + in string + complete bool + completeNoBuild bool }{ {"", false, false}, {"incomplete/mistral:7b+x", false, false}, @@ -159,6 +159,9 @@ func TestComplete(t *testing.T) { if g := p.Complete(); g != tt.complete { t.Errorf("Complete(%q) = %v; want %v", tt.in, g, tt.complete) } + if g := p.CompleteNoBuild(); g != tt.completeNoBuild { + t.Errorf("CompleteNoBuild(%q) = %v; want %v", tt.in, g, tt.completeNoBuild) + } }) }