added more strategies
This commit is contained in:
@ -36,25 +36,38 @@ func TestString(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestColor(t *testing.T) {
|
||||
testCases := []struct {
|
||||
level Level
|
||||
message string
|
||||
expected string
|
||||
func TestMarshalJSON(t *testing.T) {
|
||||
cases := []struct {
|
||||
l Level
|
||||
e string
|
||||
}{
|
||||
{Debug, "Debug message", "\033[32mDebug message\033[0m"},
|
||||
{Info, "Info message", "\033[97mInfo message\033[0m"},
|
||||
{Warn, "Warning message", "\033[33mWarning message\033[0m"},
|
||||
{Error, "Error message", "\033[31mError message\033[0m"},
|
||||
{
|
||||
l: Debug,
|
||||
e: `"Debug"`,
|
||||
},
|
||||
{
|
||||
l: Info,
|
||||
e: `"Info"`,
|
||||
},
|
||||
{
|
||||
l: Warn,
|
||||
e: `"Warn"`,
|
||||
},
|
||||
{
|
||||
l: Error,
|
||||
e: `"Error"`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
coloredMessage := tc.level.Colorize(tc.message)
|
||||
if coloredMessage != tc.expected {
|
||||
t.Errorf("For level %v, expected '%v', but got '%v'", tc.level, tc.expected, coloredMessage)
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.e, func(t *testing.T) {
|
||||
res, _ := c.l.MarshalJSON()
|
||||
|
||||
if string(res) != c.e {
|
||||
t.Errorf("Expected %s but got %s", c.e, res)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user