Skip to content

Commit

Permalink
Merge pull request #3 from seipan/tests/level
Browse files Browse the repository at this point in the history
tests(level) : add level testcode
  • Loading branch information
seipan authored Aug 9, 2023
2 parents 17a885a + cb1d0bc commit 67d04e5
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions level_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,57 @@ import "testing"

func Test_String(t *testing.T) {
tests := []struct {
name Level
name string
level Level
reqmessage string
}{
{
name: InfoLevel,
name: "success info level",
level: InfoLevel,
reqmessage: "info",
},
{
name: ErrorLevel,
name: "success error level",
level: ErrorLevel,
reqmessage: "error",
},
}

for _, tt := range tests {
if tt.reqmessage != tt.name.String() {
t.Error("level to string err")
t.Run(tt.name, func(t *testing.T) {
if tt.reqmessage != tt.level.String() {
t.Error("level to string err")
}
})
}
}

func TestParseLevel(t *testing.T) {
tests := []struct {
name string
reqlvl Level
reqstr string
}{
{
name: "success info level",
reqlvl: InfoLevel,
reqstr: "info",
},
{
name: "success error level",
reqlvl: ErrorLevel,
reqstr: "error",
},
}

for _, tt := range tests {
res, err := ParseLevel(tt.reqstr)
if err != nil {
t.Error(err)
}

if tt.reqlvl != res {
t.Errorf("parse level err want %v, got %v", tt.reqlvl, res)
}
}
}

0 comments on commit 67d04e5

Please sign in to comment.