0.3.22 - PINs
This commit is contained in:
@@ -420,6 +420,33 @@ func TestHomeForYouWindowAt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientLocalNowPrefersTheClientHeaderOverTheHousehold(t *testing.T) {
|
||||
household := time.Date(2026, time.July, 29, 23, 30, 0, 0, time.UTC)
|
||||
r := httptest.NewRequest(http.MethodGet, "/v1/home", nil)
|
||||
r.Header.Set(clientLocalHourHeader, "7")
|
||||
|
||||
got := clientLocalNow(r, household)
|
||||
if got.Hour() != 7 {
|
||||
t.Fatalf("hour = %d, want 7", got.Hour())
|
||||
}
|
||||
if got.Year() != 2026 || got.Month() != time.July || got.Day() != 29 {
|
||||
t.Fatalf("date changed unexpectedly: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientLocalNowFallsBackWithoutAUsableHeader(t *testing.T) {
|
||||
household := time.Date(2026, time.July, 29, 23, 30, 0, 0, time.UTC)
|
||||
for _, header := range []string{"", "not-a-number", "24", "-1"} {
|
||||
r := httptest.NewRequest(http.MethodGet, "/v1/home", nil)
|
||||
if header != "" {
|
||||
r.Header.Set(clientLocalHourHeader, header)
|
||||
}
|
||||
if got := clientLocalNow(r, household); !got.Equal(household) {
|
||||
t.Fatalf("header %q: got %v, want fallback %v", header, got, household)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecommendationBuildsAreDeduplicatedPerUser(t *testing.T) {
|
||||
var builds recommendationBuilds
|
||||
|
||||
|
||||
Reference in New Issue
Block a user