-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathnim_test.go
More file actions
86 lines (81 loc) · 1.84 KB
/
Copy pathnim_test.go
File metadata and controls
86 lines (81 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package commands
import (
"testing"
)
func TestIsNIMImage(t *testing.T) {
tests := []struct {
name string
model string
expected bool
}{
{
name: "NIM image with full path",
model: "nvcr.io/nim/google/gemma-3-1b-it:latest",
expected: true,
},
{
name: "NIM image without tag",
model: "nvcr.io/nim/meta/llama-3.1-8b-instruct",
expected: true,
},
{
name: "Regular Docker Hub image",
model: "docker.io/library/ubuntu:latest",
expected: false,
},
{
name: "Regular image without registry",
model: "ubuntu:latest",
expected: false,
},
{
name: "HuggingFace model",
model: "hf.co/TheBloke/Llama-2-7B-Chat-GGUF",
expected: false,
},
{
name: "Local model path",
model: "./models/llama-2-7b.gguf",
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := isNIMImage(tt.model)
if result != tt.expected {
t.Errorf("isNIMImage(%q) = %v, want %v", tt.model, result, tt.expected)
}
})
}
}
func TestNIMContainerName(t *testing.T) {
tests := []struct {
name string
model string
expected string
}{
{
name: "NIM image with tag",
model: "nvcr.io/nim/google/gemma-3-1b-it:latest",
expected: "docker-model-nim-google-gemma-3-1b-it",
},
{
name: "NIM image without tag",
model: "nvcr.io/nim/meta/llama-3.1-8b-instruct",
expected: "docker-model-nim-meta-llama-3.1-8b-instruct",
},
{
name: "NIM image with version tag",
model: "nvcr.io/nim/nvidia/nemo:24.01",
expected: "docker-model-nim-nvidia-nemo",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := nimContainerName(tt.model)
if result != tt.expected {
t.Errorf("nimContainerName(%q) = %q, want %q", tt.model, result, tt.expected)
}
})
}
}