diff --git a/api.go b/api.go index e57f55e6c1d43d5954bcbca94805ce1f5ef8c018..f77f1c7e54750960b6c82e0471fabc69afef5b90 100644 --- a/api.go +++ b/api.go @@ -38,7 +38,7 @@ func (s *setting[C]) SetMnemonic(mnemonic string) *setting[C] { } // Check if the setting contains errors -func (s *setting[C]) HasError() bool { +func (s *setting[C]) HasErrors() bool { return len(s.errors) > 0 } diff --git a/change_test.go b/change_test.go index 849406942e9184f26a8a45e49ed1fe769cb58ddf..7e1b6616ecc7f7b931cf4ebe16f95e0e07656a03 100644 --- a/change_test.go +++ b/change_test.go @@ -69,7 +69,7 @@ func TestCangeOnChange(t *testing.T) { s.Import() - if s.HasError() { + if s.HasErrors() { t.Error("Expected not error", s.Errors()) } diff --git a/error.go b/error.go index 8d9f5ee2fdd7fb97f4a748e97ae591ad0af0148b..a6c93fe578f2f5e10ee16a89ac282802037fa84a 100644 --- a/error.go +++ b/error.go @@ -50,7 +50,7 @@ func newUnsupportedTypeError(t reflect.Type) UnsupportedTypeError { } // ResetError is used to reset the error to nil -// After calling this function, the call HasError() will return false +// After calling this function, the call HasErrors() will return false func (s *setting[C]) ResetErrors() *setting[C] { s.errors = []error{} return s diff --git a/error_test.go b/error_test.go index 877004fe4644173fd07d14a70c6539153b6679ab..0e58e86c4e71d60b44801920c1522c07c8ee2db2 100644 --- a/error_test.go +++ b/error_test.go @@ -14,11 +14,11 @@ func TestResetErrors(t *testing.T) { c := New(defaults) - assert.False(t, c.HasError()) + assert.False(t, c.HasErrors()) c.SetDefaultDirectories() - assert.True(t, c.HasError()) + assert.True(t, c.HasErrors()) c.ResetErrors() - assert.False(t, c.HasError()) + assert.False(t, c.HasErrors()) } func TestNewFlagDoesNotExistError(t *testing.T) { diff --git a/export_test.go b/export_test.go index 6709cb30f9189722263b2613167d7c1868213ebe..8d87c1336b0d858a5c8fa8c9afbd93dcc06d5abd 100644 --- a/export_test.go +++ b/export_test.go @@ -21,7 +21,7 @@ func TestWrite(t *testing.T) { s.Write(x, f) - if s.HasError() { + if s.HasErrors() { t.Error(s.Errors()) s.ResetErrors() continue diff --git a/file_test.go b/file_test.go index 29241d1a07aec99a6e406f3a2d03e3aa1549de38..677d43ebd50269b0f1f083c147b0a217ef6dd03f 100644 --- a/file_test.go +++ b/file_test.go @@ -167,7 +167,7 @@ func TestAddDirectoryMissingMnemonic(t *testing.T) { c := New(cfg) c.AddEtcDirectory() - if !c.HasError() { + if !c.HasErrors() { t.Error("Expected error") } @@ -260,7 +260,7 @@ func TestSetFileFormat(t *testing.T) { c := New(cfg) c.SetFileFormat(Yaml) - if c.HasError() { + if c.HasErrors() { t.Error("Expected not error") } @@ -273,7 +273,7 @@ func TestSetFileFormatError(t *testing.T) { c := New(cfg) c.SetFileFormat(Format(9999)) - if !c.HasError() { + if !c.HasErrors() { t.Error("Expected error") } @@ -302,7 +302,7 @@ func TestImport(t *testing.T) { c.SetDefaultDirectories().ResetErrors() c.Import() - if c.HasError() { + if c.HasErrors() { t.Error("Expected not error", c.Errors()) } @@ -413,7 +413,7 @@ func TestImport2(t *testing.T) { c.SetDefaultDirectories().ResetErrors() // errors not important here c.Import() - if c.HasError() { + if c.HasErrors() { t.Error("Expected not error", c.Errors()) } @@ -461,7 +461,7 @@ func TestImport3(t *testing.T) { c.SetDefaultDirectories().ResetErrors() // errors not important here c.Import() - if c.HasError() { + if c.HasErrors() { t.Error("Expected not error", c.Errors()) } @@ -514,7 +514,7 @@ func TestSetConfigName(t *testing.T) { c := New(cfg) c.SetFileName("test") - if c.HasError() { + if c.HasErrors() { t.Error("Expected not error") } @@ -527,13 +527,13 @@ func TestConfigSetFileName(t *testing.T) { c := New(cfg) c.SetFileName("test") - if c.HasError() { + if c.HasErrors() { t.Error("Expected not error") } c.SetFileName("") - if !c.HasError() { + if !c.HasErrors() { t.Error("Expected error") } @@ -546,7 +546,7 @@ func TestConfigSetFileFormat(t *testing.T) { c := New(cfg) c.SetFileFormat(99) - if !c.HasError() { + if !c.HasErrors() { t.Error("Expected not error") } @@ -559,7 +559,7 @@ func TestConfigSetDirectories(t *testing.T) { c := New(cfg) c.SetDirectories([]string{"a", "b"}) - if !c.HasError() { + if !c.HasErrors() { t.Error("Expected not error") } @@ -572,7 +572,7 @@ func TestConfigDirectories(t *testing.T) { c := New(cfg) c.SetDirectories([]string{"a", "b"}) - if !c.HasError() { + if !c.HasErrors() { t.Error("Expected not error") } @@ -591,7 +591,7 @@ func TestConfigAddDirectory(t *testing.T) { c := New(cfg) c.AddDirectory("a") - if !c.HasError() { + if !c.HasErrors() { t.Error("Expected not error") } diff --git a/http-handler.go b/http-handler.go index a0255951fe1a94c26d4dac72b12b1374ab2e66c3..59b3e94187eba2a5ba3f5e02d912b6c7d8f769dd 100644 --- a/http-handler.go +++ b/http-handler.go @@ -47,7 +47,7 @@ func (s *setting[C]) serveGet(w http.ResponseWriter, r *http.Request) { } - if s.HasError() { + if s.HasErrors() { w.WriteHeader(http.StatusInternalServerError) return } diff --git a/integration_test.go b/integration_test.go index e1b10bda342ea01399e30d81ed114f22e3b48772..60ff24a393a090539d17904509c2e5163c2a77f6 100644 --- a/integration_test.go +++ b/integration_test.go @@ -37,7 +37,7 @@ func FuzzTest(f *testing.F) { } s.Write(os.Stdout, Yaml) - if s.HasError() { + if s.HasErrors() { t.Error(s.Errors()) s.ResetErrors() } diff --git a/stream_test.go b/stream_test.go index 715e71005761e3aff4973f75476a2895f3011e2f..991403341f5f081d486bfe398b484f1bdd57976a 100644 --- a/stream_test.go +++ b/stream_test.go @@ -83,7 +83,7 @@ func TestAddReader(t *testing.T) { // // s.Import() // -// if s.HasError() { +// if s.HasErrors() { // t.Error("Expected no errors but got ", s.Errors()) // } // diff --git a/watch_test.go b/watch_test.go index 11b0919a881a6f2fe92d8d2a79f9f953e9db8b16..ea0b06f2ca2afb956837a061f5b0d3dfb3c88c01 100644 --- a/watch_test.go +++ b/watch_test.go @@ -82,7 +82,7 @@ func TestSettingStopWatching(t *testing.T) { c.Watch() c.StopWatching() - if c.HasError() { + if c.HasErrors() { t.Error(c.Errors()) } @@ -99,7 +99,7 @@ func TestSettingStopWatchingNotOnWatch(t *testing.T) { c := New(config) c.StopWatching() - if !c.HasError() { + if !c.HasErrors() { t.Error("Expected to have an error") }