File: message_test.go

package info (click to toggle)
golang-github-graylog2-go-gelf 0.0%2Bgit20191017.1550ee6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates, bullseye, forky, sid, trixie
  • size: 144 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package gelf

import (
	"encoding/json"
	"testing"
)

func TestWrongFieldTypes(t *testing.T) {
	msgData := map[string]string{
		"version":       `{"version": 1.1}`,
		"host":          `{"host": ["a", "b"]}`,
		"short_message": `{"short_message": {"a": "b"}}`,
		"full_message":  `{"full_message": null}`,
		"timestamp":     `{"timestamp": "12345"}`,
		"level":         `{"level": false}`,
		"facility":      `{"facility": true}`,
	}

	for k, j := range msgData {
		var msg Message
		err := json.Unmarshal([]byte(j), &msg)
		if err == nil {
			t.Errorf("expected type error on field %s", k)
		}
	}

}