2026-03-15 19:19:19 -05:00
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"reflect"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSourceConfigExpectedKinds(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
cfg SourceConfig
|
|
|
|
|
want []string
|
|
|
|
|
}{
|
|
|
|
|
{
|
2026-03-28 13:52:48 -05:00
|
|
|
name: "plural kinds normalized",
|
2026-03-15 19:19:19 -05:00
|
|
|
cfg: SourceConfig{
|
|
|
|
|
Kinds: []string{" observation ", "forecast"},
|
|
|
|
|
},
|
|
|
|
|
want: []string{"observation", "forecast"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "empty kinds",
|
|
|
|
|
cfg: SourceConfig{},
|
|
|
|
|
want: nil,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
|
got := tt.cfg.ExpectedKinds()
|
|
|
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
|
|
|
t.Fatalf("ExpectedKinds() = %#v, want %#v", got, tt.want)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSourceModeNormalize(t *testing.T) {
|
|
|
|
|
if got := SourceMode(" Poll ").Normalize(); got != SourceModePoll {
|
|
|
|
|
t.Fatalf("Normalize poll = %q, want %q", got, SourceModePoll)
|
|
|
|
|
}
|
|
|
|
|
if got := SourceMode("STREAM").Normalize(); got != SourceModeStream {
|
|
|
|
|
t.Fatalf("Normalize stream = %q, want %q", got, SourceModeStream)
|
|
|
|
|
}
|
|
|
|
|
if got := SourceMode("").Normalize(); got != SourceModeAuto {
|
|
|
|
|
t.Fatalf("Normalize auto = %q, want %q", got, SourceModeAuto)
|
|
|
|
|
}
|
|
|
|
|
}
|