Skip to content

Commit

Permalink
test: is zero value tests, error tests + removal of unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Oudwins committed Nov 1, 2024
1 parent c1f17a7 commit 1a9fa50
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
11 changes: 10 additions & 1 deletion conf/isZeroValue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ import (
"github.com/stretchr/testify/assert"
)

func TestIsZeroStringEmpty(t *testing.T) {
func TestIsZeroString(t *testing.T) {
assert.True(t, DefaultParseIsZeroValue.String(""))
assert.True(t, DefaultParseIsZeroValue.String(" "))
assert.False(t, DefaultParseIsZeroValue.String("string"))
assert.True(t, DefaultParseIsZeroValue.String(nil))
assert.True(t, DefaultParseIsZeroValue.String(0))
}

func TestIsZeroValueBool(t *testing.T) {
assert.False(t, DefaultParseIsZeroValue.Bool(false))
assert.False(t, DefaultParseIsZeroValue.Bool(true))
assert.True(t, DefaultParseIsZeroValue.Bool(nil))
assert.True(t, DefaultParseIsZeroValue.Bool(0))
}
5 changes: 0 additions & 5 deletions internals/PathBuilder.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package internals

import "strings"

type PathBuilder string

func (p PathBuilder) Push(path string) PathBuilder {
Expand All @@ -13,9 +11,6 @@ func (p PathBuilder) Push(path string) PathBuilder {
}
return p + PathBuilder("."+path)
}
func (p PathBuilder) Pop() PathBuilder {
return p[:strings.LastIndex(string(p), ".")]
}

func (p PathBuilder) String() string {
return string(p)
Expand Down
7 changes: 0 additions & 7 deletions internals/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,3 @@ func (s *ErrsMap) Add(p PathBuilder, err ZogError) {
func (s ErrsMap) IsEmpty() bool {
return s.M == nil
}

func (s ErrsMap) First() ZogError {
if s.IsEmpty() {
return nil
}
return s.M[ERROR_KEY_FIRST][0]
}
19 changes: 19 additions & 0 deletions internals/errors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package internals

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestZogErrorString(t *testing.T) {
err := ZogErr{
C: "test",
ParamsM: map[string]any{},
Typ: "string",
Val: "asda",
Msg: "asda",
}

assert.Equal(t, err.Error(), err.String())
}

0 comments on commit 1a9fa50

Please sign in to comment.