Preserve current conditions condition code presentation

This commit is contained in:
2026-06-29 12:02:37 +00:00
parent 6f8e01729d
commit 86fd848a6f
4 changed files with 31 additions and 15 deletions

View File

@@ -1361,6 +1361,9 @@ func TestCurrentConditionsMetricDefaultJSON(t *testing.T) {
if payload.Data["conditionText"] != "Rain" {
t.Fatalf("expected conditionText Rain, got %#v", payload.Data["conditionText"])
}
if payload.Data["conditionCode"] != float64(63) {
t.Fatalf("expected conditionCode 63, got %#v", payload.Data["conditionCode"])
}
}
func TestCurrentConditionsUSJSON(t *testing.T) {
@@ -1426,6 +1429,9 @@ func TestCurrentConditionsXMLAndTextFormats(t *testing.T) {
if !strings.Contains(w.Body.String(), "temperatureF") {
t.Fatalf("expected US field temperatureF in XML payload: %s", w.Body.String())
}
if !strings.Contains(w.Body.String(), "<conditionCode>2</conditionCode>") {
t.Fatalf("expected conditionCode in XML payload: %s", w.Body.String())
}
w = httptest.NewRecorder()
req = httptest.NewRequest(http.MethodGet, "/conditions/current?format=TEXT", nil)
@@ -1437,7 +1443,7 @@ func TestCurrentConditionsXMLAndTextFormats(t *testing.T) {
if !strings.Contains(w.Header().Get("Content-Type"), "text/plain") {
t.Fatalf("expected text/plain content type, got %q", w.Header().Get("Content-Type"))
}
if !strings.Contains(w.Body.String(), "Conditions text") {
if !strings.Contains(w.Body.String(), "Condition Code: 2") {
t.Fatalf("expected rendered text template body, got %q", w.Body.String())
}
}
@@ -2458,7 +2464,7 @@ func testRenderers(t *testing.T) *render.Registry {
"weatherstories.txt.tmpl": "Weather Stories",
"weatherstories_latest.txt.tmpl": "Latest Weather Story",
"alerts_active.txt.tmpl": "{{if .Data}}Active Alerts\nAlerts: {{len .Data.Alerts}}{{range .Data.Alerts}}\n{{.ID}}{{if .Headline}}\nHeadline: {{.Headline}}{{end}}{{if .Ends}}\nEnds: {{.Ends}}{{end}}{{end}}{{else}}No active alerts data available.{{end}}",
"conditions_current.txt.tmpl": "Conditions text",
"conditions_current.txt.tmpl": "Condition Code: {{.Data.ConditionCode}}",
} {
tmpl, err := template.New(name).Parse(body)
if err != nil {