-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
operations_test.go
60 lines (56 loc) · 1.43 KB
/
operations_test.go
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
package main
import (
"os"
"testing"
"github.com/sammcj/gollama/config"
)
func TestRunModel(t *testing.T) {
tests := []struct {
name string
model string
cfg *config.Config
expectDocker bool
expectError bool
skipInCI bool // Skip this test in CI
}{
{
name: "Run with Docker",
model: "test-model",
cfg: &config.Config{DockerContainer: "test-container"},
expectDocker: true,
expectError: false,
skipInCI: true,
},
{
name: "Run without Docker",
model: "test-model",
cfg: &config.Config{DockerContainer: ""},
expectDocker: false,
expectError: false,
skipInCI: true,
},
{
name: "Run with Docker set to false",
model: "test-model",
cfg: &config.Config{DockerContainer: "false"},
expectDocker: false,
expectError: false,
skipInCI: true,
},
}
for _, tt := range tests {
if tt.skipInCI && os.Getenv("CI") != "" || os.Getenv("GITHUB_ACTIONS") != "" {
t.Skip("Skipping test in CI environment")
} else {
t.Run(tt.name, func(t *testing.T) {
cmd := runModel(tt.model, tt.cfg)
if (cmd == nil) != tt.expectError {
t.Errorf("runModel() error = %v, expectError %v", cmd == nil, tt.expectError)
t.Logf("cmd: %v", cmd)
return
}
// Further assertions can be added based on how you want to validate the `tea.Cmd` returned
})
}
}
}