Skip to content

Commit

Permalink
fix(level-test) : use testify assert
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Sep 15, 2023
1 parent 72cdb82 commit b6fe2e2
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions level_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

package loghook

import "testing"
import (
"testing"

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

func TestString(t *testing.T) {
tests := []struct {
Expand All @@ -46,9 +50,7 @@ func TestString(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if tt.reqmessage != tt.level.String() {
t.Error("level to string err")
}
assert.Equal(t, tt.reqmessage, tt.level.String())
})
}
}
Expand Down Expand Up @@ -76,12 +78,8 @@ func TestParseLevel(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
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)
}
assert.NoError(t, err)
assert.Equal(t, tt.reqlvl, res)
})
}
}
Expand All @@ -108,9 +106,7 @@ func TestMarshalText(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
res := tt.reqlvl.MarshalText()
if tt.reqstr != string(res) {
t.Errorf("marshal text err want %v, got %v", tt.reqstr, string(res))
}
assert.Equal(t, tt.reqstr, res)
})
}
}

0 comments on commit b6fe2e2

Please sign in to comment.