| 48 | } |
| 49 | |
| 50 | func TestFieldClashWithTime(t *testing.T) { |
| 51 | formatter := &JSONFormatter{} |
| 52 | |
| 53 | b, err := formatter.Format(WithField("time", "right now!")) |
| 54 | if err != nil { |
| 55 | t.Fatal("Unable to format entry: ", err) |
| 56 | } |
| 57 | |
| 58 | entry := make(map[string]interface{}) |
| 59 | err = json.Unmarshal(b, &entry) |
| 60 | if err != nil { |
| 61 | t.Fatal("Unable to unmarshal formatted entry: ", err) |
| 62 | } |
| 63 | |
| 64 | if entry["fields.time"] != "right now!" { |
| 65 | t.Fatal("fields.time not set to original time field") |
| 66 | } |
| 67 | |
| 68 | if entry["time"] != "0001-01-01T00:00:00Z" { |
| 69 | t.Fatal("time field not set to current time, was: ", entry["time"]) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func TestFieldClashWithMsg(t *testing.T) { |
| 74 | formatter := &JSONFormatter{} |