package activator import ( "testing" "time" ) // Each mark records the time since the one before it, under the step's // name, so the line reads as where the wake spent its time. func TestWakeStepsNameTheTimeSinceThePreviousMark(t *testing.T) { t0 := time.Unix(1000, 0) var s wakeSteps s.begin(t0) s.mark(t0.Add(3*time.Millisecond), "checks") s.mark(t0.Add(83*time.Millisecond), "lease") s.mark(t0.Add(83400*time.Microsecond), "restore") s.mark(t0.Add(752*time.Millisecond), "spawn") if got, want := s.String(), "checks 3ms, lease 80ms, restore 0s, spawn 669ms"; got != want { t.Errorf("String = %q, want %q", got, want) } } // A wake that never began (the claim path, a nil entry) has nothing to say. func TestWakeStepsWithoutABeginRecordNothing(t *testing.T) { var s wakeSteps s.mark(time.Unix(1000, 0), "lease") if got := s.String(); got != "" { t.Errorf("String = %q, want empty", got) } }