MCPcopy Create free account
hub / github.com/Masterminds/cookoo / TestQueryParameterDatasource

Function TestQueryParameterDatasource

web/datasources_test.go:49–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestQueryParameterDatasource(t *testing.T) {
50 testUrl, err := url.ParseRequestURI("/foo?a=b&c=foo+bar&d=1234&d=5678")
51 if err != nil {
52 t.Error("! Unexpected URL parse error.")
53 }
54 ds := new(QueryParameterDatasource).Init(testUrl.Query())
55
56 // Test the string values.
57 arr := map[string]string{
58 "a": "b",
59 "c": "foo bar",
60 // url.Values.Get accesses the first value associated with a key. To get
61 // values after that you need to access the map directly.
62 "d": "1234",
63 }
64 for key, val := range arr {
65 if ds.Value(key) != val {
66 t.Error(fmt.Sprintf("! Expected '%s', got '%s'", val, ds.Value(key)))
67 }
68 }
69
70}
71
72func TestFormValuesDatasource(t *testing.T) {
73 method := "POST"

Callers

nothing calls this directly

Calls 3

InitMethod · 0.65
ValueMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected