-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathformat_test.go
More file actions
49 lines (43 loc) · 879 Bytes
/
format_test.go
File metadata and controls
49 lines (43 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package logging
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestParseFormat(t *testing.T) {
t.Parallel()
tests := []struct {
name string
value string
want Format
wantErr bool
}{
{
name: "fails with invalid string",
value: "xml",
want: noFormat,
wantErr: true,
},
{
name: "succeed with 'console'",
value: "console",
want: ConsoleFormat,
wantErr: false,
},
{
name: "succeed with 'json'",
value: "json",
want: JSONFormat,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := ParseFormat(tt.value)
if tt.wantErr {
require.Error(t, err, "ParseFormat() error = %v, wantErr %v", err, tt.wantErr)
}
require.Equal(t, tt.want, got, "ParseFormat() got = %v, want %v", got, tt.want)
})
}
}