MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / TestFindInstance

Function TestFindInstance

cmd/helpers_test.go:19–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17}
18
19func TestFindInstance(t *testing.T) {
20 instances := sampleInstances()
21
22 tests := []struct {
23 name string
24 identifier string
25 wantID string
26 wantNil bool
27 }{
28 {name: "by ID", identifier: "1", wantID: "1"},
29 {name: "by UUID", identifier: "uuid-bbb", wantID: "2"},
30 {name: "by name", identifier: "alpha", wantID: "1"},
31 {name: "not found", identifier: "nonexistent", wantNil: true},
32 {name: "empty identifier", identifier: "", wantNil: true},
33 {name: "partial ID no match", identifier: "uu", wantNil: true},
34 }
35
36 for _, tt := range tests {
37 t.Run(tt.name, func(t *testing.T) {
38 result := findInstance(instances, tt.identifier)
39 if tt.wantNil {
40 assert.Nil(t, result)
41 } else {
42 assert.NotNil(t, result)
43 assert.Equal(t, tt.wantID, result.ID)
44 }
45 })
46 }
47}
48
49func TestFindInstance_EmptyList(t *testing.T) {
50 result := findInstance([]api.Instance{}, "anything")

Callers

nothing calls this directly

Calls 2

sampleInstancesFunction · 0.85
findInstanceFunction · 0.85

Tested by

no test coverage detected