Shortened configuration struct names from JobSearchConfig to JSC since they are distinguished by being in the config package anyway
This commit is contained in:
1 parent
5ec4b65b91
commit
be4770cbab
11 files changed
+71
-67
No files matched your search
@@ -62,7 +62,7 @@ func TestDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoggingSection(t *testing.T) {
|
||||
c := JobSearchConfigLogging{Level: "info", File: "/tmp/x.log"}
|
||||
c := JSCLogging{Level: "info", File: "/tmp/x.log"}
|
||||
|
||||
if got, want := c.Keys(), []string{"level", "file"}; !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Keys = %v; want %v", got, want)
|
||||
@@ -100,7 +100,7 @@ func TestLoggingSection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoggingLevelValidation(t *testing.T) {
|
||||
var c JobSearchConfigLogging
|
||||
var c JSCLogging
|
||||
for _, lvl := range []string{"debug", "info", "warn", "error"} {
|
||||
if err := c.SetValue("level", lvl); err != nil || c.Level != lvl {
|
||||
t.Errorf("SetValue(level, %q) = %v, Level = %q", lvl, err, c.Level)
|
||||
@@ -142,7 +142,7 @@ func TestConfigLevelToLogLevel(t *testing.T) {
|
||||
if got := ConfigLevelToLogLevel(in); got != want {
|
||||
t.Errorf("ConfigLevelToLogLevel(%q) = %v; want %v", in, got, want)
|
||||
}
|
||||
c := JobSearchConfigLogging{Level: in}
|
||||
c := JSCLogging{Level: in}
|
||||
if got := c.LogLevel(); got != want {
|
||||
t.Errorf("LogLevel() with %q = %v; want %v", in, got, want)
|
||||
}
|
||||
@@ -187,9 +187,9 @@ func TestConcreteSourceSections(t *testing.T) {
|
||||
apiRoot bool
|
||||
blockShutdown bool
|
||||
}{
|
||||
{JSCKSourceFindATender, &JobSearchConfigSourceFindATender{}, true, false},
|
||||
{JSCKSourceFTSMock, &JobSearchConfigSourceFTSMock{}, true, false},
|
||||
{JSCKSourceSleeper, &JobSearchConfigSourceSleeper{}, false, true},
|
||||
{JSCKSourceFindATender, &JSCSourceFindATender{}, true, false},
|
||||
{JSCKSourceFTSMock, &JSCSourceFTSMock{}, true, false},
|
||||
{JSCKSourceSleeper, &JSCSourceSleeper{}, false, true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.prefix, func(t *testing.T) {
|
||||
@@ -252,7 +252,7 @@ func TestConcreteSourceSections(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSourcesSection(t *testing.T) {
|
||||
var c JobSearchConfigSources
|
||||
var c JSCSources
|
||||
if err := c.SetValue("fts_mock.api_root", "http://mock"); err != nil {
|
||||
t.Fatalf("SetValue: %v", err)
|
||||
}
|
||||
@@ -457,7 +457,7 @@ func TestLoadFromViperInvalidValues(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDatabaseSection(t *testing.T) {
|
||||
c := JobSearchConfigDatabase{File: "./jobsearch.db"}
|
||||
c := JSCDatabase{File: "./jobsearch.db"}
|
||||
|
||||
if got, want := c.Keys(), []string{"file"}; !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Keys = %v; want %v", got, want)
|
||||
@@ -501,6 +501,8 @@ func TestViperValue(t *testing.T) {
|
||||
viper.Set("s", "text")
|
||||
viper.Set("i", "42") // strings are converted
|
||||
viper.Set("b", "true")
|
||||
viper.Set("env_list", "a, b") // e.g. from an environment variable
|
||||
viper.Set("file_list", []any{"a", "b"}) // e.g. from a YAML list
|
||||
|
||||
for _, tt := range []struct {
|
||||
key string
|
||||
@@ -510,13 +512,15 @@ func TestViperValue(t *testing.T) {
|
||||
{"s", reflect.String, "text"},
|
||||
{"i", reflect.Int, 42},
|
||||
{"b", reflect.Bool, true},
|
||||
{"env_list", reflect.Slice, "a, b"}, // split by SetValue
|
||||
{"file_list", reflect.Slice, []string{"a", "b"}},
|
||||
} {
|
||||
got, ok := viperValue(tt.key, tt.kind)
|
||||
if !ok || got != tt.want {
|
||||
if !ok || !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("viperValue(%q, %v) = %#v, %v; want %#v", tt.key, tt.kind, got, ok, tt.want)
|
||||
}
|
||||
}
|
||||
for _, kind := range []reflect.Kind{reflect.Float64, reflect.Int8, reflect.Slice} {
|
||||
for _, kind := range []reflect.Kind{reflect.Float64, reflect.Int8, reflect.Map} {
|
||||
if got, ok := viperValue("i", kind); ok {
|
||||
t.Errorf("viperValue(i, %v) = %#v, true; want unhandled", kind, got)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user