mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-14 06:07:36 +08: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:
parent
5e1d40d910
commit
664a99cd00
@ -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{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user