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

Method TestGet

options/options_test.go:15–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13}
14
15func (s *OptionsTestSuite) TestGet() {
16 o := options.New()
17 o.Set("string_key", "string_value")
18 o.Set("bool_key", true)
19
20 // Existing keys
21 s.Require().Equal("string_value", options.Get(o, "string_key", "default_value"))
22 s.Require().True(options.Get(o, "bool_key", false))
23
24 // Non-existing keys
25 s.Require().Equal("default_value", options.Get(o, "non_existing_key", "default_value"))
26 s.Require().False(options.Get(o, "another_non_existing_key", false))
27
28 // Type mismatch
29 s.Require().Panics(func() {
30 _ = options.Get(o, "string_key", 42)
31 })
32 s.Require().Panics(func() {
33 _ = options.Get(o, "bool_key", "not_a_bool")
34 })
35}
36
37func (s *OptionsTestSuite) TestAppendToSlice() {
38 o := options.New()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
GetFunction · 0.92
SetMethod · 0.45

Tested by

no test coverage detected