| 1 | package gelf |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestWrongFieldTypes(t *testing.T) { |
| 9 | msgData := map[string]string{ |
| 10 | "version": `{"version": 1.1}`, |
| 11 | "host": `{"host": ["a", "b"]}`, |
| 12 | "short_message": `{"short_message": {"a": "b"}}`, |
| 13 | "full_message": `{"full_message": null}`, |
| 14 | "timestamp": `{"timestamp": "12345"}`, |
| 15 | "level": `{"level": false}`, |
| 16 | "facility": `{"facility": true}`, |
| 17 | } |
| 18 | |
| 19 | for k, j := range msgData { |
| 20 | var msg Message |
| 21 | err := json.Unmarshal([]byte(j), &msg) |
| 22 | if err == nil { |
| 23 | t.Errorf("expected type error on field %s", k) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | } |