(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestNewEvent(t *testing.T) { |
| 58 | t.Run("creates a new event instance", func(t *testing.T) { |
| 59 | event := newEvent("event", "id", nil) |
| 60 | // Assert that the interval between the event timestamp and now is within 1 second. |
| 61 | assert.WithinDuration(t, time.Now(), time.Unix(0, event.Timestamp*int64(1000000)), 1*time.Second) |
| 62 | assert.Equal(t, event.App, appID) |
| 63 | assert.Equal(t, event.Event, "event") |
| 64 | assert.Equal(t, event.ID, "id") |
| 65 | assert.Equal(t, event.Properties[osKey], runtime.GOOS) |
| 66 | assert.Equal(t, event.Properties[archKey], runtime.GOARCH) |
| 67 | }) |
| 68 | |
| 69 | t.Run("merges extra properties", func(t *testing.T) { |
| 70 | event := newEvent("event", "id", map[string]string{"success": "false", "error_class": "auth"}) |
| 71 | assert.Equal(t, "false", event.Properties["success"]) |
| 72 | assert.Equal(t, "auth", event.Properties["error_class"]) |
| 73 | assert.Equal(t, runtime.GOOS, event.Properties[osKey]) |
| 74 | }) |
| 75 | } |
nothing calls this directly
no test coverage detected