12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package server
- import "testing"
- func TestParseModelPath(t *testing.T) {
- tests := []struct {
- name string
- arg string
- want ModelPath
- }{
- {
- "full path https",
- "https://example.com/ns/repo:tag",
- ModelPath{
- ProtocolScheme: "https",
- Registry: "example.com",
- Namespace: "ns",
- Repository: "repo",
- Tag: "tag",
- },
- },
- {
- "full path http",
- "http://example.com/ns/repo:tag",
- ModelPath{
- ProtocolScheme: "http",
- Registry: "example.com",
- Namespace: "ns",
- Repository: "repo",
- Tag: "tag",
- },
- },
- {
- "no protocol",
- "example.com/ns/repo:tag",
- ModelPath{
- ProtocolScheme: "https",
- Registry: "example.com",
- Namespace: "ns",
- Repository: "repo",
- Tag: "tag",
- },
- },
- {
- "no registry",
- "ns/repo:tag",
- ModelPath{
- ProtocolScheme: "https",
- Registry: DefaultRegistry,
- Namespace: "ns",
- Repository: "repo",
- Tag: "tag",
- },
- },
- {
- "no namespace",
- "repo:tag",
- ModelPath{
- ProtocolScheme: "https",
- Registry: DefaultRegistry,
- Namespace: DefaultNamespace,
- Repository: "repo",
- Tag: "tag",
- },
- },
- {
- "no tag",
- "repo",
- 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)
- if got != tc.want {
- t.Errorf("got: %q want: %q", got, tc.want)
- }
- })
- }
- }
|