MCPcopy
hub / github.com/httprunner/httprunner / TestParseDataMapWithVariables

Function TestParseDataMapWithVariables

hrp/parser_test.go:293–322  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

291}
292
293func TestParseDataMapWithVariables(t *testing.T) {
294 variablesMapping := map[string]interface{}{
295 "var1": "foo1",
296 "val1": 200,
297 "var2": 123, // key is int
298 }
299
300 testData := []struct {
301 expr map[string]interface{}
302 expect interface{}
303 }{
304 {map[string]interface{}{"key": "$var1"}, map[string]interface{}{"key": "foo1"}},
305 {map[string]interface{}{"foo1": "$val1", "foo2": "bar2"}, map[string]interface{}{"foo1": 200, "foo2": "bar2"}},
306 // parse map key, key is string
307 {map[string]interface{}{"$var1": "$val1"}, map[string]interface{}{"foo1": 200}},
308 // parse map key, key is int
309 {map[string]interface{}{"$var2": "$val1"}, map[string]interface{}{"123": 200}},
310 }
311
312 parser := newParser()
313 for _, data := range testData {
314 parsedData, err := parser.Parse(data.expr, variablesMapping)
315 if !assert.NoError(t, err) {
316 t.Fatal()
317 }
318 if !assert.Equal(t, data.expect, parsedData) {
319 t.Fatal()
320 }
321 }
322}
323
324func TestParseHeaders(t *testing.T) {
325 variablesMapping := map[string]interface{}{

Callers

nothing calls this directly

Calls 2

newParserFunction · 0.85
ParseMethod · 0.80

Tested by

no test coverage detected