MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestSingleTimer

Function TestSingleTimer

tstest/clock_test.go:943–1448  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

941}
942
943func TestSingleTimer(t *testing.T) {
944 t.Parallel()
945
946 type testStep struct {
947 stop bool
948 stopReturn bool // The expected return value for Stop() if stop is true.
949 reset time.Duration
950 resetAbsolute time.Time
951 resetReturn bool // The expected return value for Reset() or ResetAbsolute().
952 setStep time.Duration
953 advance time.Duration
954 advanceRealTime time.Duration
955 wantTime time.Time
956 wantTicks []time.Time
957 }
958
959 tests := []struct {
960 name string
961 realTimeOpts *ClockOpts
962 start time.Time
963 step time.Duration
964 delay time.Duration
965 steps []testStep
966 }{
967 {
968 name: "no-tick-advance",
969 start: time.Unix(12345, 0),
970 delay: time.Second,
971 steps: []testStep{
972 {
973 advance: time.Second - 1,
974 wantTime: time.Unix(12345, 999_999_999),
975 },
976 },
977 },
978 {
979 name: "no-tick-step",
980 start: time.Unix(12345, 0),
981 step: time.Second - 1,
982 delay: time.Second,
983 steps: []testStep{
984 {
985 wantTime: time.Unix(12345, 0),
986 },
987 {
988 wantTime: time.Unix(12345, 999_999_999),
989 },
990 },
991 },
992 {
993 name: "single-tick-advance-exact",
994 start: time.Unix(12345, 0),
995 delay: time.Second,
996 steps: []testStep{
997 {
998 advance: time.Second,
999 wantTime: time.Unix(12346, 0),
1000 wantTicks: []time.Time{time.Unix(12346, 0)},

Callers

nothing calls this directly

Calls 15

AdvanceMethod · 0.95
NewClockFunction · 0.85
newClockInternalFunction · 0.85
expectNoTicksFunction · 0.85
SetStepMethod · 0.80
RunMethod · 0.65
NewTimerMethod · 0.65
CleanupMethod · 0.65
StopMethod · 0.65
ErrorfMethod · 0.65
IsZeroMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…