-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from grafana/consolidate-log-level-flags
deprecate -log-level=<int> / map -log.level=<string> to a ssh log level
- Loading branch information
Showing
4 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestLogLevelToSSHLogLevel(t *testing.T) { | ||
t.Parallel() | ||
|
||
cases := []struct { | ||
description string | ||
level string | ||
expectedLevel int | ||
expectedErr error | ||
}{ | ||
{ | ||
description: "error becomes 0", | ||
level: "error", | ||
expectedLevel: 0, | ||
}, | ||
{ | ||
description: "warn becomes 0", | ||
level: "warn", | ||
expectedLevel: 0, | ||
}, | ||
{ | ||
description: "info becomes 0", | ||
level: "info", | ||
expectedLevel: 0, | ||
}, | ||
{ | ||
description: "debug becomes 3", | ||
level: "debug", | ||
expectedLevel: 3, | ||
}, | ||
{ | ||
description: "unknown level, should return error", | ||
level: "unknown", | ||
expectedErr: errors.New("invalid log level: unknown"), | ||
}, | ||
} | ||
|
||
for _, tt := range cases { | ||
tt := tt | ||
t.Run(tt.description, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
actual, err := logLevelToSSHLogLevel(tt.level) | ||
|
||
if tt.expectedErr != nil { | ||
assert.Equal(t, tt.expectedErr, err) | ||
} else { | ||
assert.Equal(t, tt.expectedLevel, actual) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters