| 47 | } |
| 48 | |
| 49 | func 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 | |
| 72 | func TestFormValuesDatasource(t *testing.T) { |
| 73 | method := "POST" |