| 30 | } |
| 31 | |
| 32 | func TestNew_UsesInjectedClockAndID(t *testing.T) { |
| 33 | t.Parallel() |
| 34 | fixed := time.Date(2024, 1, 2, 3, 4, 5, 0, time.UTC) |
| 35 | |
| 36 | s := New(WithClock(fixedClock(fixed)), WithIDGen(stubIDs(t, "test-session-1"))) |
| 37 | |
| 38 | if s.ID != "test-session-1" { |
| 39 | t.Errorf("ID = %q, want %q", s.ID, "test-session-1") |
| 40 | } |
| 41 | if !s.CreatedAt.Equal(fixed) { |
| 42 | t.Errorf("CreatedAt = %v, want %v", s.CreatedAt, fixed) |
| 43 | } |
| 44 | if !s.SendUserMessage { |
| 45 | t.Error("SendUserMessage should default to true") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestNew_WithIDOverridesGenerator(t *testing.T) { |
| 50 | t.Parallel() |