Initial MVP commit
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:
38
internal/adapters/postgres/queries_test.go
Normal file
38
internal/adapters/postgres/queries_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user