mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-14 06:07:36 +08:00
style: fix indentation in Test_setLogLevel
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
aa16e7ae26
commit
1fc553f102
@ -78,42 +78,42 @@ func TestContentAppearanceFlagValidation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_setLogLevel(t *testing.T) {
|
func Test_setLogLevel(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
lvl string
|
lvl string
|
||||||
}
|
}
|
||||||
tests := map[string]struct {
|
tests := map[string]struct {
|
||||||
args args
|
args args
|
||||||
want log.Level
|
want log.Level
|
||||||
expectedErr string
|
expectedErr string
|
||||||
}{
|
}{
|
||||||
"invalid": {args: args{lvl: "INVALID"}, want: log.LevelInfo, expectedErr: "unknown log level: INVALID"},
|
"invalid": {args: args{lvl: "INVALID"}, want: log.LevelInfo, expectedErr: "unknown log level: INVALID"},
|
||||||
"empty": {args: args{lvl: ""}, want: log.LevelInfo, expectedErr: "unknown log level: "},
|
"empty": {args: args{lvl: ""}, want: log.LevelInfo, expectedErr: "unknown log level: "},
|
||||||
"info": {args: args{lvl: log.LevelInfo.String()}, want: log.LevelInfo},
|
"info": {args: args{lvl: log.LevelInfo.String()}, want: log.LevelInfo},
|
||||||
"debug": {args: args{lvl: log.LevelDebug.String()}, want: log.LevelDebug},
|
"debug": {args: args{lvl: log.LevelDebug.String()}, want: log.LevelDebug},
|
||||||
"trace": {args: args{lvl: log.LevelTrace.String()}, want: log.LevelTrace},
|
"trace": {args: args{lvl: log.LevelTrace.String()}, want: log.LevelTrace},
|
||||||
"warning": {args: args{lvl: log.LevelWarning.String()}, want: log.LevelWarning},
|
"warning": {args: args{lvl: log.LevelWarning.String()}, want: log.LevelWarning},
|
||||||
"error": {args: args{lvl: log.LevelError.String()}, want: log.LevelError},
|
"error": {args: args{lvl: log.LevelError.String()}, want: log.LevelError},
|
||||||
"fatal": {args: args{lvl: log.LevelFatal.String()}, want: log.LevelFatal},
|
"fatal": {args: args{lvl: log.LevelFatal.String()}, want: log.LevelFatal},
|
||||||
}
|
}
|
||||||
for name, tt := range tests {
|
for name, tt := range tests {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
cmd := &cli.Command{
|
cmd := &cli.Command{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "log-level",
|
Name: "log-level",
|
||||||
Value: tt.args.lvl,
|
Value: tt.args.lvl,
|
||||||
Usage: "set the log level. Possible values: TRACE, DEBUG, INFO, WARNING, ERROR, FATAL.",
|
Usage: "set the log level. Possible values: TRACE, DEBUG, INFO, WARNING, ERROR, FATAL.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err := SetLogLevel(cmd)
|
err := SetLogLevel(cmd)
|
||||||
if tt.expectedErr != "" {
|
if tt.expectedErr != "" {
|
||||||
assert.EqualError(t, err, tt.expectedErr)
|
assert.EqualError(t, err, tt.expectedErr)
|
||||||
} else {
|
} else {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, tt.want, log.GetLevel())
|
assert.Equal(t, tt.want, log.GetLevel())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user