Compare commits
2 Commits
main
...
brucemacd/
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a5bc4b7c17 | ||
![]() |
1be080403d |
@ -802,6 +802,12 @@ func PushModel(ctx context.Context, name string, regOpts *registryOptions, fn fu
|
|||||||
if mp.ProtocolScheme == "http" && !regOpts.Insecure {
|
if mp.ProtocolScheme == "http" && !regOpts.Insecure {
|
||||||
return errors.New("insecure protocol http")
|
return errors.New("insecure protocol http")
|
||||||
}
|
}
|
||||||
|
if mp.Namespace != strings.ToLower(mp.Namespace) {
|
||||||
|
return fmt.Errorf("namespace must be lowercase, but is %s", mp.Namespace)
|
||||||
|
}
|
||||||
|
if mp.Repository != strings.ToLower(mp.Repository) {
|
||||||
|
return fmt.Errorf("model name must be lowercase, but is %s", mp.Repository)
|
||||||
|
}
|
||||||
|
|
||||||
manifest, _, err := GetManifest(mp)
|
manifest, _, err := GetManifest(mp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
50
server/images_test.go
Normal file
50
server/images_test.go
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ollama/ollama/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPushModel(t *testing.T) {
|
||||||
|
noOpProgress := func(resp api.ProgressResponse) {}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
modelStr string
|
||||||
|
regOpts *registryOptions
|
||||||
|
wantErr string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
modelStr: "http://example.com/namespace/repo:tag",
|
||||||
|
regOpts: ®istryOptions{Insecure: false},
|
||||||
|
wantErr: "insecure protocol http",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
modelStr: "docker://Example/repo:tag",
|
||||||
|
regOpts: ®istryOptions{},
|
||||||
|
wantErr: "namespace must be lowercase, but is Example",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
modelStr: "docker://example/Repo:tag",
|
||||||
|
regOpts: ®istryOptions{},
|
||||||
|
wantErr: "model name must be lowercase, but is Repo",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.modelStr, func(t *testing.T) {
|
||||||
|
err := PushModel(context.Background(), tt.modelStr, tt.regOpts, noOpProgress)
|
||||||
|
|
||||||
|
if tt.wantErr != "" {
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("PushModel() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
} else if !strings.Contains(err.Error(), tt.wantErr) {
|
||||||
|
t.Errorf("PushModel() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user