mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-01 21:02:33 +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 {
|
for name, tt := range tests {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
|
prev := log.GetLevel()
|
||||||
|
t.Cleanup(func() { log.SetLevel(prev) })
|
||||||
cmd := &cli.Command{
|
cmd := &cli.Command{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
|||||||
Reference in New Issue
Block a user