ollama/server/modelpath_test.go

89 lines
1.6 KiB
Go
Raw Normal View History

2023-08-22 04:56:56 +00:00
package server
import "testing"
func TestParseModelPath(t *testing.T) {
tests := []struct {
name string
arg string
2023-08-22 04:56:56 +00:00
want ModelPath
}{
{
"full path https",
"https://example.com/ns/repo:tag",
2023-08-22 04:56:56 +00:00
ModelPath{
ProtocolScheme: "https",
Registry: "example.com",
Namespace: "ns",
Repository: "repo",
Tag: "tag",
},
},
{
"full path http",
"http://example.com/ns/repo:tag",
2023-08-22 04:56:56 +00:00
ModelPath{
ProtocolScheme: "http",
Registry: "example.com",
Namespace: "ns",
Repository: "repo",
Tag: "tag",
},
},
{
"no protocol",
"example.com/ns/repo:tag",
2023-08-22 04:56:56 +00:00
ModelPath{
ProtocolScheme: "https",
Registry: "example.com",
Namespace: "ns",
Repository: "repo",
Tag: "tag",
},
},
{
"no registry",
"ns/repo:tag",
2023-08-22 04:56:56 +00:00
ModelPath{
ProtocolScheme: "https",
Registry: DefaultRegistry,
Namespace: "ns",
Repository: "repo",
Tag: "tag",
},
},
{
"no namespace",
"repo:tag",
2023-08-22 04:56:56 +00:00
ModelPath{
ProtocolScheme: "https",
Registry: DefaultRegistry,
Namespace: DefaultNamespace,
Repository: "repo",
Tag: "tag",
},
},
{
"no tag",
"repo",
2023-08-22 04:56:56 +00:00
ModelPath{
ProtocolScheme: "https",
Registry: DefaultRegistry,
Namespace: DefaultNamespace,
Repository: "repo",
Tag: DefaultTag,
},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got := ParseModelPath(tc.arg)
2023-08-22 04:56:56 +00:00
if got != tc.want {
t.Errorf("got: %q want: %q", got, tc.want)
}
})
}
}