Cleanup outlook endpoints and completed roadmap documentation
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful

This commit is contained in:
2026-06-12 09:40:49 -05:00
parent 6316783c3a
commit f4dd701204
11 changed files with 43 additions and 429 deletions

View File

@@ -1484,13 +1484,15 @@ func TestOutlookRoutesRegistered(t *testing.T) {
for _, path := range []string{
"/outlooks/convective",
"/outlooks/convective/active",
"/outlooks/convective/location",
} {
def := definitionForPath(t, defs, path)
if len(def.Methods) != 1 || def.Methods[0] != http.MethodGet {
t.Fatalf("%s: expected GET definition, got %+v", path, def.Methods)
}
}
if endpointExists(defs, "/outlooks/convective/location") {
t.Fatal("expected /outlooks/convective/location to be removed")
}
}
func TestOutlookRoutesJSONSuccess(t *testing.T) {
@@ -1499,7 +1501,6 @@ func TestOutlookRoutesJSONSuccess(t *testing.T) {
for _, path := range []string{
"/outlooks/convective",
"/outlooks/convective/active",
"/outlooks/convective/location",
} {
t.Run(path, func(t *testing.T) {
h := newHandler(t, &fakeService{outlookRun: testOutlookRun()}, path)
@@ -1676,7 +1677,7 @@ func TestOutlookQueryParamsConstructFilter(t *testing.T) {
h := newHandler(t, svc, "/outlooks/convective")
w := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/outlooks/convective?day=2&outlookType=Tornado&containsLocation=true&tz=CDT&units=US", nil)
req := httptest.NewRequest(http.MethodGet, "/outlooks/convective?day=2&outlookType=Tornado&tz=CDT&units=US", nil)
h.ServeHTTP(w, req)
if w.Code != http.StatusOK {
@@ -1692,15 +1693,12 @@ func TestOutlookQueryParamsConstructFilter(t *testing.T) {
if filter.OutlookType != "tornado" {
t.Fatalf("expected outlookType tornado, got %q", filter.OutlookType)
}
if filter.ContainsLocation == nil || !*filter.ContainsLocation {
t.Fatalf("expected containsLocation true, got %+v", filter.ContainsLocation)
}
if filter.ActiveAt != nil {
t.Fatalf("expected no active filter, got %v", filter.ActiveAt)
}
}
func TestOutlookActiveAndLocationFiltersUseNow(t *testing.T) {
func TestOutlookActiveFilterUsesNow(t *testing.T) {
now := time.Date(2026, 6, 11, 15, 30, 0, 0, time.FixedZone("CDT", -5*3600))
setOutlookNowForTest(t, now)
@@ -1716,28 +1714,6 @@ func TestOutlookActiveAndLocationFiltersUseNow(t *testing.T) {
if activeFilter.ActiveAt == nil || !activeFilter.ActiveAt.Equal(now.UTC()) {
t.Fatalf("expected activeAt %s, got %v", now.UTC(), activeFilter.ActiveAt)
}
if activeFilter.ContainsLocation != nil {
t.Fatalf("expected active route not to force containsLocation, got %+v", activeFilter.ContainsLocation)
}
locationSvc := &fakeService{outlookRun: testOutlookRun()}
locationHandler := newHandler(t, locationSvc, "/outlooks/convective/location")
w = httptest.NewRecorder()
req = httptest.NewRequest(http.MethodGet, "/outlooks/convective/location?outlookType=hail", nil)
locationHandler.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Fatalf("expected location 200, got %d", w.Code)
}
locationFilter := locationSvc.outlookFilters[0]
if locationFilter.ActiveAt == nil || !locationFilter.ActiveAt.Equal(now.UTC()) {
t.Fatalf("expected location activeAt %s, got %v", now.UTC(), locationFilter.ActiveAt)
}
if locationFilter.ContainsLocation == nil || !*locationFilter.ContainsLocation {
t.Fatalf("expected location route to force containsLocation true, got %+v", locationFilter.ContainsLocation)
}
if locationFilter.OutlookType != "hail" {
t.Fatalf("expected outlookType hail, got %q", locationFilter.OutlookType)
}
}
func TestOutlookInvalidQueryParamsReturnBadRequest(t *testing.T) {
@@ -1748,10 +1724,10 @@ func TestOutlookInvalidQueryParamsReturnBadRequest(t *testing.T) {
"/outlooks/convective?day=4",
"/outlooks/convective?day=two",
"/outlooks/convective?outlookType=snow",
"/outlooks/convective?containsLocation=maybe",
"/outlooks/convective?containsLocation=true",
"/outlooks/convective/active?containsLocation=true",
"/outlooks/convective?tz=not-a-timezone",
"/outlooks/convective?tz=CDT&TZ=EST",
"/outlooks/convective/location?containsLocation=true",
} {
t.Run(rawURL, func(t *testing.T) {
h := newHandler(t, &fakeService{outlookRun: testOutlookRun()}, strings.Split(rawURL, "?")[0])
@@ -2440,6 +2416,15 @@ func definitionForPath(t *testing.T, defs []endpoint.Definition, path string) en
return endpoint.Definition{}
}
func endpointExists(defs []endpoint.Definition, path string) bool {
for _, def := range defs {
if def.Path == path {
return true
}
}
return false
}
func testRenderers(t *testing.T) *render.Registry {
t.Helper()