MCPcopy
hub / github.com/minio/minio-go / TestCustomQueryParameters

Function TestCustomQueryParameters

get-options_test.go:61–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestCustomQueryParameters(t *testing.T) {
62 var (
63 paramKey = "x-test-param"
64 paramValue = "test-value"
65
66 invalidParamKey = "invalid-test-param"
67 invalidParamValue = "invalid-test-param"
68 )
69
70 testCases := []struct {
71 setParamsFunc func(o *GetObjectOptions)
72 }{
73 {func(o *GetObjectOptions) {
74 o.AddReqParam(paramKey, paramValue)
75 o.AddReqParam(invalidParamKey, invalidParamValue)
76 }},
77 {func(o *GetObjectOptions) {
78 o.SetReqParam(paramKey, paramValue)
79 o.SetReqParam(invalidParamKey, invalidParamValue)
80 }},
81 }
82
83 for i, testCase := range testCases {
84 opts := GetObjectOptions{}
85 testCase.setParamsFunc(&opts)
86
87 // This and the following checks indirectly ensure that only the expected
88 // valid header is added.
89 if len(opts.reqParams) != 1 {
90 t.Errorf("Test %d: Expected 1 kv-pair in query parameters, got %v", i+1, len(opts.reqParams))
91 }
92
93 if v, ok := opts.reqParams[paramKey]; !ok {
94 t.Errorf("Test %d: Expected query parameter with key %s missing", i+1, paramKey)
95 } else if len(v) != 1 {
96 t.Errorf("Test %d: Expected 1 value for query parameter with key %s, got %d values", i+1, paramKey, len(v))
97 } else if v[0] != paramValue {
98 t.Errorf("Test %d: Expected query value %s for key %s, got %s", i+1, paramValue, paramKey, v[0])
99 }
100 }
101}

Callers

nothing calls this directly

Calls 2

AddReqParamMethod · 0.80
SetReqParamMethod · 0.80

Tested by

no test coverage detected