Code cleanup and deduplication pass through weatherfeeder
This commit is contained in:
@@ -47,13 +47,42 @@ func TestRegisterBuiltinsDoesNotRegisterLegacyNWSForecastDriver(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterBuiltinsRegistersAllCurrentDrivers(t *testing.T) {
|
||||
reg := fksource.NewRegistry()
|
||||
RegisterBuiltins(reg)
|
||||
|
||||
drivers := []string{
|
||||
"nws_observation",
|
||||
"nws_alerts",
|
||||
"nws_forecast_hourly",
|
||||
"nws_forecast_narrative",
|
||||
"openmeteo_observation",
|
||||
"openmeteo_forecast",
|
||||
"openweather_observation",
|
||||
}
|
||||
|
||||
for _, driver := range drivers {
|
||||
in, err := reg.BuildInput(sourceConfigForDriver(driver))
|
||||
if err != nil {
|
||||
t.Fatalf("BuildInput(%s) error = %v", driver, err)
|
||||
}
|
||||
if _, ok := in.(fksource.PollSource); !ok {
|
||||
t.Fatalf("BuildInput(%s) type = %T, want PollSource", driver, in)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sourceConfigForDriver(driver string) config.SourceConfig {
|
||||
url := "https://example.invalid"
|
||||
if driver == "openweather_observation" {
|
||||
url = "https://example.invalid?units=metric"
|
||||
}
|
||||
return config.SourceConfig{
|
||||
Name: "test-source",
|
||||
Driver: driver,
|
||||
Mode: config.SourceModePoll,
|
||||
Params: map[string]any{
|
||||
"url": "https://example.invalid",
|
||||
"url": url,
|
||||
"user_agent": "test-agent",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user