diff --git a/docs/config.md b/docs/config.md index 4118ed0..47805c5 100644 --- a/docs/config.md +++ b/docs/config.md @@ -43,7 +43,7 @@ config test suite. - `base_url`: absolute base URL for the Weather API. Required for generation and collection workflows. - `timeout`: HTTP timeout duration. Default: `10s`. -- `precision`: numeric precision query value. Default: `1`. +- `precision`: numeric precision query value. Default: `0`, which requests integer values where supported. - `units`: Weather API units query value. Default: `us`. - `timezone`: report timezone and Weather API timezone query value where supported. Default: `America/Chicago`. - `format`: Weather API response format. Must be `json`. Default: `json`. diff --git a/docs/integrations/weatherapi.md b/docs/integrations/weatherapi.md index 0a8d9f7..b40391d 100644 --- a/docs/integrations/weatherapi.md +++ b/docs/integrations/weatherapi.md @@ -69,7 +69,8 @@ The adapter sends these query parameters: - `format`: from `weather_api.format`; configuration validation requires `json` - `units`: from `weather_api.units` - `precision`: from `weather_api.precision` on observations, current - conditions, hourly forecast, and narrative forecast requests + conditions, hourly forecast, and narrative forecast requests; the built-in + default is `0` - `tz`: from `weather_api.timezone` on hourly forecast, narrative forecast, discussion, and SPC convective outlook requests diff --git a/examples/config.yml b/examples/config.yml index a1e7707..40f7bc3 100644 --- a/examples/config.yml +++ b/examples/config.yml @@ -1,7 +1,7 @@ weather_api: base_url: https://weather.api.example.com/ timeout: 15s - precision: 1 + precision: 0 units: us timezone: "America/Chicago" format: json diff --git a/internal/adapters/weatherapi/client_test.go b/internal/adapters/weatherapi/client_test.go index 405a9fe..21741bc 100644 --- a/internal/adapters/weatherapi/client_test.go +++ b/internal/adapters/weatherapi/client_test.go @@ -135,9 +135,15 @@ func TestFetchBundleBuildsExpectedQueries(t *testing.T) { t.Fatalf("request %q missing units=us", rawURL) } if strings.HasPrefix(rawURL, "/forecast/") { - if !strings.Contains(rawURL, "precision=1") || !strings.Contains(rawURL, "tz=America%2FChicago") { + if !strings.Contains(rawURL, "precision=0") || !strings.Contains(rawURL, "tz=America%2FChicago") { t.Fatalf("forecast request %q missing precision or tz", rawURL) } + continue + } + if rawURL == defaultWarmupEndpoint || strings.HasPrefix(rawURL, defaultWarmupEndpoint+"?") || strings.HasPrefix(rawURL, "/observations?") { + if !strings.Contains(rawURL, "precision=0") { + t.Fatalf("request %q missing precision=0", rawURL) + } } } } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 3b32df8..e08ef42 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -28,6 +28,9 @@ func TestDefaults(t *testing.T) { if cfg.WeatherAPI.Format != "json" { t.Fatalf("Format = %q, want json", cfg.WeatherAPI.Format) } + if cfg.WeatherAPI.Precision != 0 { + t.Fatalf("Precision = %d, want 0", cfg.WeatherAPI.Precision) + } if cfg.Location.ID != "home" || cfg.Location.Name != "Brentwood" || cfg.Location.Region != "St. Louis Metro" { t.Fatalf("Location = %#v, want home/Brentwood/St. Louis Metro", cfg.Location) } diff --git a/internal/config/defaults.go b/internal/config/defaults.go index df68a9e..e2964a5 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -8,7 +8,7 @@ func Defaults() Config { return Config{ WeatherAPI: WeatherAPIConfig{ Timeout: 10 * time.Second, - Precision: 1, + Precision: 0, Units: "us", Timezone: "America/Chicago", Format: "json",