just to verify that the function is available, real tests are in TestExtractQueryParam
(t *testing.T)
| 161 | |
| 162 | // just to verify that the function is available, real tests are in TestExtractQueryParam |
| 163 | func TestExtractQueryParamExpr(t *testing.T) { |
| 164 | err := Init(nil) |
| 165 | require.NoError(t, err) |
| 166 | |
| 167 | tests := []struct { |
| 168 | name string |
| 169 | env map[string]any |
| 170 | code string |
| 171 | result []string |
| 172 | err string |
| 173 | }{ |
| 174 | { |
| 175 | name: "ExtractQueryParam() test: basic test", |
| 176 | env: map[string]any{ |
| 177 | "query": "/foo?a=1&b=2", |
| 178 | }, |
| 179 | code: "ExtractQueryParam(query, 'a')", |
| 180 | result: []string{"1"}, |
| 181 | }, |
| 182 | } |
| 183 | for _, test := range tests { |
| 184 | program, err := expr.Compile(test.code, GetExprOptions(test.env)...) |
| 185 | require.NoError(t, err) |
| 186 | output, err := expr.Run(program, test.env) |
| 187 | require.NoError(t, err) |
| 188 | require.Equal(t, test.result, output) |
| 189 | log.Printf("test '%s' : OK", test.name) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // just to verify that the function is available, real tests are in TestParseQuery |
| 194 | func TestParseQueryInExpr(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…