mirror of
https://github.com/kovetskiy/mark.git
synced 2026-04-21 22:12:35 +00:00
test: restore global log level after each SetLogLevel subtest
SetLogLevel mutates a process-global logger, leaking state into subsequent tests and causing order-dependent failures. Save the current level before each subtest and restore it via t.Cleanup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -97,6 +97,8 @@ func Test_setLogLevel(t *testing.T) {
|
||||
}
|
||||
for name, tt := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
prev := log.GetLevel()
|
||||
t.Cleanup(func() { log.SetLevel(prev) })
|
||||
cmd := &cli.Command{
|
||||
Name: "test",
|
||||
Flags: []cli.Flag{
|
||||
|
||||
Reference in New Issue
Block a user