MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestAppendToSlice

Method TestAppendToSlice

options/options_test.go:37–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37func (s *OptionsTestSuite) TestAppendToSlice() {
38 o := options.New()
39 o.Set("slice", []int{1, 2, 3})
40
41 // Append to existing slice
42 options.AppendToSlice(o, "slice", 4, 5)
43 s.Require().Equal([]int{1, 2, 3, 4, 5}, options.Get(o, "slice", []int{}))
44
45 // Append to non-existing slice
46 options.AppendToSlice(o, "new_slice", 10, 20)
47 s.Require().Equal([]int{10, 20}, options.Get(o, "new_slice", []int{}))
48
49 // Type mismatch
50 s.Require().Panics(func() {
51 options.AppendToSlice(o, "slice", "not_an_int")
52 })
53}
54
55func (s *OptionsTestSuite) TestSliceContains() {
56 o := options.New()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
AppendToSliceFunction · 0.92
GetFunction · 0.92
SetMethod · 0.45

Tested by

no test coverage detected