(t *testing.T)
| 2880 | } |
| 2881 | |
| 2882 | func TestGetVarNames(t *testing.T) { |
| 2883 | r := NewRouter() |
| 2884 | |
| 2885 | route := r.Host("{domain}"). |
| 2886 | Path("/{group}/{item_id}"). |
| 2887 | Queries("some_data1", "{some_data1}"). |
| 2888 | Queries("some_data2_and_3", "{some_data2}.{some_data3}") |
| 2889 | |
| 2890 | // Order of vars in the slice is not guaranteed, so just check for existence |
| 2891 | expected := map[string]bool{ |
| 2892 | "domain": true, |
| 2893 | "group": true, |
| 2894 | "item_id": true, |
| 2895 | "some_data1": true, |
| 2896 | "some_data2": true, |
| 2897 | "some_data3": true, |
| 2898 | } |
| 2899 | |
| 2900 | varNames, err := route.GetVarNames() |
| 2901 | if err != nil { |
| 2902 | t.Fatal(err) |
| 2903 | } |
| 2904 | |
| 2905 | if len(varNames) != len(expected) { |
| 2906 | t.Fatalf("expected %d names, got %d", len(expected), len(varNames)) |
| 2907 | } |
| 2908 | |
| 2909 | for _, varName := range varNames { |
| 2910 | if !expected[varName] { |
| 2911 | t.Fatalf("got unexpected %s", varName) |
| 2912 | } |
| 2913 | } |
| 2914 | } |
| 2915 | |
| 2916 | // mapToPairs converts a string map to a slice of string pairs |
| 2917 | func mapToPairs(m map[string]string) []string { |
nothing calls this directly
no test coverage detected