mirror of https://github.com/ollama/ollama.git
				
				
				
			
		
			
				
	
	
		
			89 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			89 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
| 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)
 | |
| 			}
 | |
| 		})
 | |
| 	}
 | |
| }
 |