Skip to content
Snippets Groups Projects
Verified Commit 7143b273 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

change api HasError() to HasErrors() as it is more logical

parent b4f686d3
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ func (s *setting[C]) SetMnemonic(mnemonic string) *setting[C] { ...@@ -38,7 +38,7 @@ func (s *setting[C]) SetMnemonic(mnemonic string) *setting[C] {
} }
// Check if the setting contains errors // Check if the setting contains errors
func (s *setting[C]) HasError() bool { func (s *setting[C]) HasErrors() bool {
return len(s.errors) > 0 return len(s.errors) > 0
} }
......
...@@ -69,7 +69,7 @@ func TestCangeOnChange(t *testing.T) { ...@@ -69,7 +69,7 @@ func TestCangeOnChange(t *testing.T) {
s.Import() s.Import()
if s.HasError() { if s.HasErrors() {
t.Error("Expected not error", s.Errors()) t.Error("Expected not error", s.Errors())
} }
......
...@@ -50,7 +50,7 @@ func newUnsupportedTypeError(t reflect.Type) UnsupportedTypeError { ...@@ -50,7 +50,7 @@ func newUnsupportedTypeError(t reflect.Type) UnsupportedTypeError {
} }
// ResetError is used to reset the error to nil // 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] { func (s *setting[C]) ResetErrors() *setting[C] {
s.errors = []error{} s.errors = []error{}
return s return s
......
...@@ -14,11 +14,11 @@ func TestResetErrors(t *testing.T) { ...@@ -14,11 +14,11 @@ func TestResetErrors(t *testing.T) {
c := New(defaults) c := New(defaults)
assert.False(t, c.HasError()) assert.False(t, c.HasErrors())
c.SetDefaultDirectories() c.SetDefaultDirectories()
assert.True(t, c.HasError()) assert.True(t, c.HasErrors())
c.ResetErrors() c.ResetErrors()
assert.False(t, c.HasError()) assert.False(t, c.HasErrors())
} }
func TestNewFlagDoesNotExistError(t *testing.T) { func TestNewFlagDoesNotExistError(t *testing.T) {
......
...@@ -21,7 +21,7 @@ func TestWrite(t *testing.T) { ...@@ -21,7 +21,7 @@ func TestWrite(t *testing.T) {
s.Write(x, f) s.Write(x, f)
if s.HasError() { if s.HasErrors() {
t.Error(s.Errors()) t.Error(s.Errors())
s.ResetErrors() s.ResetErrors()
continue continue
......
...@@ -167,7 +167,7 @@ func TestAddDirectoryMissingMnemonic(t *testing.T) { ...@@ -167,7 +167,7 @@ func TestAddDirectoryMissingMnemonic(t *testing.T) {
c := New(cfg) c := New(cfg)
c.AddEtcDirectory() c.AddEtcDirectory()
if !c.HasError() { if !c.HasErrors() {
t.Error("Expected error") t.Error("Expected error")
} }
...@@ -260,7 +260,7 @@ func TestSetFileFormat(t *testing.T) { ...@@ -260,7 +260,7 @@ func TestSetFileFormat(t *testing.T) {
c := New(cfg) c := New(cfg)
c.SetFileFormat(Yaml) c.SetFileFormat(Yaml)
if c.HasError() { if c.HasErrors() {
t.Error("Expected not error") t.Error("Expected not error")
} }
...@@ -273,7 +273,7 @@ func TestSetFileFormatError(t *testing.T) { ...@@ -273,7 +273,7 @@ func TestSetFileFormatError(t *testing.T) {
c := New(cfg) c := New(cfg)
c.SetFileFormat(Format(9999)) c.SetFileFormat(Format(9999))
if !c.HasError() { if !c.HasErrors() {
t.Error("Expected error") t.Error("Expected error")
} }
...@@ -302,7 +302,7 @@ func TestImport(t *testing.T) { ...@@ -302,7 +302,7 @@ func TestImport(t *testing.T) {
c.SetDefaultDirectories().ResetErrors() c.SetDefaultDirectories().ResetErrors()
c.Import() c.Import()
if c.HasError() { if c.HasErrors() {
t.Error("Expected not error", c.Errors()) t.Error("Expected not error", c.Errors())
} }
...@@ -413,7 +413,7 @@ func TestImport2(t *testing.T) { ...@@ -413,7 +413,7 @@ func TestImport2(t *testing.T) {
c.SetDefaultDirectories().ResetErrors() // errors not important here c.SetDefaultDirectories().ResetErrors() // errors not important here
c.Import() c.Import()
if c.HasError() { if c.HasErrors() {
t.Error("Expected not error", c.Errors()) t.Error("Expected not error", c.Errors())
} }
...@@ -461,7 +461,7 @@ func TestImport3(t *testing.T) { ...@@ -461,7 +461,7 @@ func TestImport3(t *testing.T) {
c.SetDefaultDirectories().ResetErrors() // errors not important here c.SetDefaultDirectories().ResetErrors() // errors not important here
c.Import() c.Import()
if c.HasError() { if c.HasErrors() {
t.Error("Expected not error", c.Errors()) t.Error("Expected not error", c.Errors())
} }
...@@ -514,7 +514,7 @@ func TestSetConfigName(t *testing.T) { ...@@ -514,7 +514,7 @@ func TestSetConfigName(t *testing.T) {
c := New(cfg) c := New(cfg)
c.SetFileName("test") c.SetFileName("test")
if c.HasError() { if c.HasErrors() {
t.Error("Expected not error") t.Error("Expected not error")
} }
...@@ -527,13 +527,13 @@ func TestConfigSetFileName(t *testing.T) { ...@@ -527,13 +527,13 @@ func TestConfigSetFileName(t *testing.T) {
c := New(cfg) c := New(cfg)
c.SetFileName("test") c.SetFileName("test")
if c.HasError() { if c.HasErrors() {
t.Error("Expected not error") t.Error("Expected not error")
} }
c.SetFileName("") c.SetFileName("")
if !c.HasError() { if !c.HasErrors() {
t.Error("Expected error") t.Error("Expected error")
} }
...@@ -546,7 +546,7 @@ func TestConfigSetFileFormat(t *testing.T) { ...@@ -546,7 +546,7 @@ func TestConfigSetFileFormat(t *testing.T) {
c := New(cfg) c := New(cfg)
c.SetFileFormat(99) c.SetFileFormat(99)
if !c.HasError() { if !c.HasErrors() {
t.Error("Expected not error") t.Error("Expected not error")
} }
...@@ -559,7 +559,7 @@ func TestConfigSetDirectories(t *testing.T) { ...@@ -559,7 +559,7 @@ func TestConfigSetDirectories(t *testing.T) {
c := New(cfg) c := New(cfg)
c.SetDirectories([]string{"a", "b"}) c.SetDirectories([]string{"a", "b"})
if !c.HasError() { if !c.HasErrors() {
t.Error("Expected not error") t.Error("Expected not error")
} }
...@@ -572,7 +572,7 @@ func TestConfigDirectories(t *testing.T) { ...@@ -572,7 +572,7 @@ func TestConfigDirectories(t *testing.T) {
c := New(cfg) c := New(cfg)
c.SetDirectories([]string{"a", "b"}) c.SetDirectories([]string{"a", "b"})
if !c.HasError() { if !c.HasErrors() {
t.Error("Expected not error") t.Error("Expected not error")
} }
...@@ -591,7 +591,7 @@ func TestConfigAddDirectory(t *testing.T) { ...@@ -591,7 +591,7 @@ func TestConfigAddDirectory(t *testing.T) {
c := New(cfg) c := New(cfg)
c.AddDirectory("a") c.AddDirectory("a")
if !c.HasError() { if !c.HasErrors() {
t.Error("Expected not error") t.Error("Expected not error")
} }
......
...@@ -47,7 +47,7 @@ func (s *setting[C]) serveGet(w http.ResponseWriter, r *http.Request) { ...@@ -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) w.WriteHeader(http.StatusInternalServerError)
return return
} }
......
...@@ -37,7 +37,7 @@ func FuzzTest(f *testing.F) { ...@@ -37,7 +37,7 @@ func FuzzTest(f *testing.F) {
} }
s.Write(os.Stdout, Yaml) s.Write(os.Stdout, Yaml)
if s.HasError() { if s.HasErrors() {
t.Error(s.Errors()) t.Error(s.Errors())
s.ResetErrors() s.ResetErrors()
} }
......
...@@ -83,7 +83,7 @@ func TestAddReader(t *testing.T) { ...@@ -83,7 +83,7 @@ func TestAddReader(t *testing.T) {
// //
// s.Import() // s.Import()
// //
// if s.HasError() { // if s.HasErrors() {
// t.Error("Expected no errors but got ", s.Errors()) // t.Error("Expected no errors but got ", s.Errors())
// } // }
// //
......
...@@ -82,7 +82,7 @@ func TestSettingStopWatching(t *testing.T) { ...@@ -82,7 +82,7 @@ func TestSettingStopWatching(t *testing.T) {
c.Watch() c.Watch()
c.StopWatching() c.StopWatching()
if c.HasError() { if c.HasErrors() {
t.Error(c.Errors()) t.Error(c.Errors())
} }
...@@ -99,7 +99,7 @@ func TestSettingStopWatchingNotOnWatch(t *testing.T) { ...@@ -99,7 +99,7 @@ func TestSettingStopWatchingNotOnWatch(t *testing.T) {
c := New(config) c := New(config)
c.StopWatching() c.StopWatching()
if !c.HasError() { if !c.HasErrors() {
t.Error("Expected to have an error") t.Error("Expected to have an error")
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment