Added new endpoints under /forecast/narrative
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
type fakeRepository struct {
|
||||
observation *model.WeatherObservation
|
||||
forecast *model.WeatherForecastRun
|
||||
narrative *model.WeatherForecastRun
|
||||
alerts *model.WeatherAlertRun
|
||||
conditions *CurrentConditions
|
||||
err error
|
||||
@@ -28,6 +29,10 @@ func (r *fakeRepository) LatestHourlyForecast(context.Context) (*model.WeatherFo
|
||||
return r.forecast, r.err
|
||||
}
|
||||
|
||||
func (r *fakeRepository) LatestNarrativeForecast(context.Context) (*model.WeatherForecastRun, error) {
|
||||
return r.narrative, r.err
|
||||
}
|
||||
|
||||
func (r *fakeRepository) LatestAlertRun(context.Context) (*model.WeatherAlertRun, error) {
|
||||
return r.alerts, r.err
|
||||
}
|
||||
@@ -63,6 +68,19 @@ func TestServiceDelegatesForecast(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceDelegatesNarrativeForecast(t *testing.T) {
|
||||
repo := &fakeRepository{narrative: &model.WeatherForecastRun{LocationID: "stl-narrative"}}
|
||||
svc := NewService(repo)
|
||||
|
||||
run, err := svc.LatestNarrativeForecast(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if run == nil || run.LocationID != "stl-narrative" {
|
||||
t.Fatalf("unexpected forecast: %+v", run)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceDelegatesAlerts(t *testing.T) {
|
||||
repo := &fakeRepository{alerts: &model.WeatherAlertRun{LocationID: "stl"}}
|
||||
svc := NewService(repo)
|
||||
|
||||
Reference in New Issue
Block a user