All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package postgres
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/ejr/weatherapi/internal/platform/constants"
|
|
)
|
|
|
|
func TestQueriesUseParametersNotHardcodedValues(t *testing.T) {
|
|
if !strings.Contains(queryObservationSummary, "make_interval(mins => $1)") {
|
|
t.Fatalf("observation summary query must use $1 minutes parameter")
|
|
}
|
|
if strings.Contains(queryObservationSummary, "30 minutes") {
|
|
t.Fatalf("observation summary query should not hardcode 30 minutes")
|
|
}
|
|
|
|
if !strings.Contains(queryObservationConditions, "make_interval(mins => $1)") {
|
|
t.Fatalf("observation conditions query must use $1 minutes parameter")
|
|
}
|
|
if !strings.Contains(queryObservationPrecipitation, "make_interval(mins => $1)") {
|
|
t.Fatalf("observation precipitation query must use $1 minutes parameter")
|
|
}
|
|
|
|
if !strings.Contains(queryForecastPeriodsAt, "LIMIT $2") {
|
|
t.Fatalf("forecast query must use parameterized limit")
|
|
}
|
|
if strings.Contains(queryForecastPeriodsAt, "LIMIT 5") {
|
|
t.Fatalf("forecast query should not hardcode limit=5")
|
|
}
|
|
}
|
|
|
|
func TestWindowMinutesUsesObservationWindowConstant(t *testing.T) {
|
|
got := windowMinutes(constants.ObservationWindow)
|
|
if got != 30 {
|
|
t.Fatalf("expected 30 minutes from constants.ObservationWindow, got %d", got)
|
|
}
|
|
}
|