Add maintained configuration examples
This commit is contained in:
@@ -24,7 +24,7 @@ sources:
|
||||
# driver: openweather_observation
|
||||
# every: 10m
|
||||
# params:
|
||||
# url: "https://api.openweathermap.org/data/2.5/weather?lat=38.6239&lon=-90.3571&appid=c954f2566cb7ccb56b43737b52e88fc6&units=metric"
|
||||
# url: "https://api.openweathermap.org/data/2.5/weather?lat=38.6239&lon=-90.3571&units=metric"
|
||||
# user_agent: "HomeOps (eric@maximumdirect.net)"
|
||||
|
||||
# - name: NWSObservationKSUS
|
||||
@@ -115,7 +115,7 @@ sinks:
|
||||
# params:
|
||||
# uri: postgres://weatherdb:5432/weatherdb?sslmode=disable
|
||||
# username: weatherdb
|
||||
# password: weatherdb
|
||||
# password: <database_password>
|
||||
# prune: 3d
|
||||
# # Prunes rows older than now-3d on each write transaction.
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -82,6 +84,33 @@ func TestExampleConfigSourcesBuildSchedulerJobs(t *testing.T) {
|
||||
t.Fatalf("config.Load(config.yml) unexpected error: %v", err)
|
||||
}
|
||||
|
||||
assertConfigSourcesBuildSchedulerJobs(t, cfg)
|
||||
}
|
||||
|
||||
func TestMaintainedConfigExamplesLoad(t *testing.T) {
|
||||
paths, err := filepath.Glob("../../examples/*.yml")
|
||||
if err != nil {
|
||||
t.Fatalf("filepath.Glob examples: %v", err)
|
||||
}
|
||||
sort.Strings(paths)
|
||||
if len(paths) == 0 {
|
||||
t.Fatalf("expected maintained config examples")
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
t.Run(filepath.Base(path), func(t *testing.T) {
|
||||
cfg, err := config.Load(path)
|
||||
if err != nil {
|
||||
t.Fatalf("config.Load(%s) unexpected error: %v", path, err)
|
||||
}
|
||||
assertConfigSourcesBuildSchedulerJobs(t, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func assertConfigSourcesBuildSchedulerJobs(t *testing.T, cfg *config.Config) {
|
||||
t.Helper()
|
||||
|
||||
reg := fksources.NewRegistry()
|
||||
wfsources.RegisterBuiltins(reg)
|
||||
|
||||
@@ -91,6 +120,10 @@ func TestExampleConfigSourcesBuildSchedulerJobs(t *testing.T) {
|
||||
t.Fatalf("BuildInput(sources[%d]) error = %v", i, err)
|
||||
}
|
||||
|
||||
if err := fksources.ValidateExpectedKinds(sc, in); err != nil {
|
||||
t.Fatalf("ValidateExpectedKinds(sources[%d]) error = %v", i, err)
|
||||
}
|
||||
|
||||
job, err := fkscheduler.JobFromSourceConfig(in, sc)
|
||||
if err != nil {
|
||||
t.Fatalf("JobFromSourceConfig(sources[%d]) error = %v", i, err)
|
||||
|
||||
Reference in New Issue
Block a user