(t *testing.T)
| 175 | } |
| 176 | |
| 177 | func Test_parseInsightsInterval_week(t *testing.T) { |
| 178 | t.Parallel() |
| 179 | |
| 180 | layout := insightsTimeLayout |
| 181 | losAngelesLoc, err := time.LoadLocation("America/Los_Angeles") // Random location |
| 182 | require.NoError(t, err) |
| 183 | |
| 184 | now := time.Now().In(losAngelesLoc) |
| 185 | t.Logf("now: %s", now) |
| 186 | |
| 187 | y, m, d := now.Date() |
| 188 | today := time.Date(y, m, d, 0, 0, 0, 0, losAngelesLoc) |
| 189 | t.Logf("today: %s", today) |
| 190 | |
| 191 | thisHour := time.Date(y, m, d, now.Hour(), 0, 0, 0, losAngelesLoc) |
| 192 | t.Logf("thisHour: %s", thisHour) |
| 193 | twoHoursAgo := thisHour.Add(-2 * time.Hour) |
| 194 | t.Logf("twoHoursAgo: %s", twoHoursAgo) |
| 195 | thirteenDaysAgo := today.AddDate(0, 0, -13) |
| 196 | t.Logf("thirteenDaysAgo: %s", thirteenDaysAgo) |
| 197 | |
| 198 | sixDaysAgo := today.AddDate(0, 0, -6) |
| 199 | t.Logf("sixDaysAgo: %s", sixDaysAgo) |
| 200 | nineDaysAgo := today.AddDate(0, 0, -9) |
| 201 | t.Logf("nineDaysAgo: %s", nineDaysAgo) |
| 202 | |
| 203 | type args struct { |
| 204 | startTime string |
| 205 | endTime string |
| 206 | } |
| 207 | tests := []struct { |
| 208 | name string |
| 209 | args args |
| 210 | wantOk bool |
| 211 | }{ |
| 212 | { |
| 213 | name: "Two full weeks", |
| 214 | args: args{ |
| 215 | startTime: "2023-08-10T00:00:00+02:00", |
| 216 | endTime: "2023-08-24T00:00:00+02:00", |
| 217 | }, |
| 218 | wantOk: true, |
| 219 | }, |
| 220 | { |
| 221 | name: "One full week", |
| 222 | args: args{ |
| 223 | startTime: "2023-09-06T00:00:00+02:00", |
| 224 | endTime: "2023-09-13T00:00:00+02:00", |
| 225 | }, |
| 226 | wantOk: true, |
| 227 | }, |
| 228 | /* FIXME: daylight savings issue |
| 229 | { |
| 230 | name: "6 days are acceptable", |
| 231 | args: args{ |
| 232 | startTime: sixDaysAgo.Format(layout), |
| 233 | endTime: stripTime(thisHour).Format(layout), |
| 234 | }, |
nothing calls this directly
no test coverage detected