MCPcopy
hub / github.com/helm/helm / TestSetIndex

Function TestSetIndex

pkg/strvals/parser_test.go:26–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestSetIndex(t *testing.T) {
27 tests := []struct {
28 name string
29 initial []any
30 expect []any
31 add int
32 val int
33 err bool
34 }{
35 {
36 name: "short",
37 initial: []any{0, 1},
38 expect: []any{0, 1, 2},
39 add: 2,
40 val: 2,
41 err: false,
42 },
43 {
44 name: "equal",
45 initial: []any{0, 1},
46 expect: []any{0, 2},
47 add: 1,
48 val: 2,
49 err: false,
50 },
51 {
52 name: "long",
53 initial: []any{0, 1, 2, 3, 4, 5},
54 expect: []any{0, 1, 2, 4, 4, 5},
55 add: 3,
56 val: 4,
57 err: false,
58 },
59 {
60 name: "negative",
61 initial: []any{0, 1, 2, 3, 4, 5},
62 expect: []any{0, 1, 2, 3, 4, 5},
63 add: -1,
64 val: 4,
65 err: true,
66 },
67 {
68 name: "large",
69 initial: []any{0, 1, 2, 3, 4, 5},
70 expect: []any{0, 1, 2, 3, 4, 5},
71 add: MaxIndex + 1,
72 val: 4,
73 err: true,
74 },
75 }
76
77 for _, tt := range tests {
78 got, err := setIndex(tt.initial, tt.add, tt.val)
79
80 if err != nil && tt.err == false {
81 t.Fatalf("%s: Expected no error but error returned", tt.name)
82 } else if err == nil && tt.err == true {
83 t.Fatalf("%s: Expected error but no error returned", tt.name)

Callers

nothing calls this directly

Calls 2

setIndexFunction · 0.85
FatalfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…