-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathreinstall-runner_test.go
More file actions
76 lines (64 loc) · 1.88 KB
/
Copy pathreinstall-runner_test.go
File metadata and controls
76 lines (64 loc) · 1.88 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
package commands
import (
"testing"
)
func TestReinstallRunnerHostFlag(t *testing.T) {
testCases := []struct {
name string
value string
}{
{"localhost", "127.0.0.1"},
{"all_interfaces", "0.0.0.0"},
{"specific_IP", "192.168.1.100"},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
// Reset the command for each test
cmd := newReinstallRunner()
err := cmd.Flags().Set("host", tc.value)
if err != nil {
t.Errorf("Failed to set host flag to '%s': %v", tc.value, err)
}
// Verify the value was set
hostValue, err := cmd.Flags().GetString("host")
if err != nil {
t.Errorf("Failed to get host flag value: %v", err)
}
if hostValue != tc.value {
t.Errorf("Expected host value to be '%s', got '%s'", tc.value, hostValue)
}
})
}
}
func TestReinstallRunnerCommandFlags(t *testing.T) {
cmd := newReinstallRunner()
// Verify all expected flags exist
expectedFlags := []string{"port", "host", "gpu", "backend", "do-not-track"}
for _, flagName := range expectedFlags {
if cmd.Flags().Lookup(flagName) == nil {
t.Errorf("Expected flag '--%s' not found", flagName)
}
}
}
func TestReinstallRunnerCommandType(t *testing.T) {
cmd := newReinstallRunner()
// Verify command properties
if cmd.Use != "reinstall-runner" {
t.Errorf("Expected command Use to be 'reinstall-runner', got '%s'", cmd.Use)
}
if cmd.Short != "Reinstall Docker Model Runner (Docker Engine only)" {
t.Errorf("Unexpected command Short description: %s", cmd.Short)
}
// Verify RunE is set
if cmd.RunE == nil {
t.Error("Expected RunE to be set")
}
}
func TestReinstallRunnerValidArgsFunction(t *testing.T) {
cmd := newReinstallRunner()
// The reinstall-runner command should not accept any arguments
// So ValidArgsFunction should be set to handle no arguments
if cmd.ValidArgsFunction == nil {
t.Error("Expected ValidArgsFunction to be set")
}
}