(t *testing.T)
| 163 | } |
| 164 | |
| 165 | func TestIsWithinRange(t *testing.T) { |
| 166 | t.Parallel() |
| 167 | testCases := []struct { |
| 168 | name string |
| 169 | spec string |
| 170 | at time.Time |
| 171 | expectedWithinRange bool |
| 172 | expectedError string |
| 173 | }{ |
| 174 | // "* 9-18 * * 1-5" should be interpreted as a continuous time range from 09:00:00 to 18:59:59, Monday through Friday |
| 175 | { |
| 176 | name: "Right before the start of the time range", |
| 177 | spec: "* 9-18 * * 1-5", |
| 178 | at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 8:59:59 UTC"), |
| 179 | expectedWithinRange: false, |
| 180 | }, |
| 181 | { |
| 182 | name: "Start of the time range", |
| 183 | spec: "* 9-18 * * 1-5", |
| 184 | at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 9:00:00 UTC"), |
| 185 | expectedWithinRange: true, |
| 186 | }, |
| 187 | { |
| 188 | name: "9:01 AM - One minute after the start of the time range", |
| 189 | spec: "* 9-18 * * 1-5", |
| 190 | at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 9:01:00 UTC"), |
| 191 | expectedWithinRange: true, |
| 192 | }, |
| 193 | { |
| 194 | name: "2PM - The middle of the time range", |
| 195 | spec: "* 9-18 * * 1-5", |
| 196 | at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 14:00:00 UTC"), |
| 197 | expectedWithinRange: true, |
| 198 | }, |
| 199 | { |
| 200 | name: "6PM - One hour before the end of the time range", |
| 201 | spec: "* 9-18 * * 1-5", |
| 202 | at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 18:00:00 UTC"), |
| 203 | expectedWithinRange: true, |
| 204 | }, |
| 205 | { |
| 206 | name: "End of the time range", |
| 207 | spec: "* 9-18 * * 1-5", |
| 208 | at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 18:59:59 UTC"), |
| 209 | expectedWithinRange: true, |
| 210 | }, |
| 211 | { |
| 212 | name: "Right after the end of the time range", |
| 213 | spec: "* 9-18 * * 1-5", |
| 214 | at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 19:00:00 UTC"), |
| 215 | expectedWithinRange: false, |
| 216 | }, |
| 217 | { |
| 218 | name: "7:01PM - One minute after the end of the time range", |
| 219 | spec: "* 9-18 * * 1-5", |
| 220 | at: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 19:01:00 UTC"), |
| 221 | expectedWithinRange: false, |
| 222 | }, |
nothing calls this directly
no test coverage detected