(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestGetValueWithKey(t *testing.T) { |
| 11 | tests := []struct { |
| 12 | data map[string]any |
| 13 | key string |
| 14 | want any |
| 15 | }{ |
| 16 | { |
| 17 | data: map[string]any{ |
| 18 | "user": "test", |
| 19 | }, |
| 20 | key: "user", |
| 21 | want: "test", |
| 22 | }, |
| 23 | { |
| 24 | data: map[string]any{ |
| 25 | "data": map[string]any{ |
| 26 | "user": "test", |
| 27 | }, |
| 28 | }, |
| 29 | key: "data.user", |
| 30 | want: "test", |
| 31 | }, |
| 32 | } |
| 33 | |
| 34 | for _, test := range tests { |
| 35 | got := GetValueWithKey(test.data, test.key) |
| 36 | if test.want != got { |
| 37 | t.Errorf("GetValueWithKey got %v but want %v", got, test.want) |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func TestGetValueWithKeyFromJSONString(t *testing.T) { |
| 43 | tests := []struct { |
nothing calls this directly
no test coverage detected