MCPcopy Create free account
hub / github.com/coder/coder / TestMatchesCron

Function TestMatchesCron

coderd/prebuilds/preset_snapshot_test.go:1171–1204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1169}
1170
1171func TestMatchesCron(t *testing.T) {
1172 t.Parallel()
1173 testCases := []struct {
1174 name string
1175 spec string
1176 at time.Time
1177 expectedMatches bool
1178 }{
1179 // A comprehensive test suite for time range evaluation is implemented in TestIsWithinRange.
1180 // This test provides only basic coverage.
1181 {
1182 name: "Right before the start of the time range",
1183 spec: "* 9-18 * * 1-5",
1184 at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 8:59:59 UTC"),
1185 expectedMatches: false,
1186 },
1187 {
1188 name: "Start of the time range",
1189 spec: "* 9-18 * * 1-5",
1190 at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 9:00:00 UTC"),
1191 expectedMatches: true,
1192 },
1193 }
1194
1195 for _, testCase := range testCases {
1196 t.Run(testCase.name, func(t *testing.T) {
1197 t.Parallel()
1198
1199 matches, err := prebuilds.MatchesCron(testCase.spec, testCase.at)
1200 require.NoError(t, err)
1201 require.Equal(t, testCase.expectedMatches, matches)
1202 })
1203 }
1204}
1205
1206func TestCalculateDesiredInstances(t *testing.T) {
1207 t.Parallel()

Callers

nothing calls this directly

Calls 4

MatchesCronFunction · 0.92
mustParseTimeFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected