MCPcopy Index your code
hub / github.com/docker/docker-agent / TestWithMessageOptions_UseInjectedClock

Function TestWithMessageOptions_UseInjectedClock

pkg/session/clock_test.go:103–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestWithMessageOptions_UseInjectedClock(t *testing.T) {
104 t.Parallel()
105 fixed := time.Date(2024, 3, 4, 5, 6, 7, 0, time.UTC)
106 want := fixed.Format(time.RFC3339)
107
108 s := New(
109 WithClock(fixedClock(fixed)),
110 WithUserMessage("user"),
111 WithSystemMessage("system"),
112 WithImplicitUserMessage("implicit"),
113 )
114
115 if len(s.Messages) != 3 {
116 t.Fatalf("len(Messages) = %d, want 3", len(s.Messages))
117 }
118 for i, item := range s.Messages {
119 if item.Message.Message.CreatedAt != want {
120 t.Errorf("Messages[%d].CreatedAt = %q, want %q", i, item.Message.Message.CreatedAt, want)
121 }
122 }
123}
124
125func TestDuration_DeterministicWithExplicitTimestamps(t *testing.T) {
126 t.Parallel()

Callers

nothing calls this directly

Calls 6

fixedClockFunction · 0.85
WithUserMessageFunction · 0.85
WithSystemMessageFunction · 0.85
WithImplicitUserMessageFunction · 0.85
NewFunction · 0.70
WithClockFunction · 0.70

Tested by

no test coverage detected