test: address PR review follow-ups for OAuth and logger cleanup
Restore logger config via t.Cleanup after t.Setenv so Yuque token tests do not leak global state, add unit tests for MCP OAuth non-interactive context helpers and IM auth notice formatting, and fix EmbedChatCore indentation.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -98,6 +99,24 @@ func TestLanguageLocaleName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMCPOAuthNonInteractive(t *testing.T) {
|
||||
if IsMCPOAuthNonInteractive(nil) {
|
||||
t.Fatal("nil context should not be non-interactive")
|
||||
}
|
||||
if IsMCPOAuthNonInteractive(context.Background()) {
|
||||
t.Fatal("background context should not be non-interactive")
|
||||
}
|
||||
|
||||
ctx := WithMCPOAuthNonInteractive(context.Background())
|
||||
if !IsMCPOAuthNonInteractive(ctx) {
|
||||
t.Fatal("marked context should be non-interactive")
|
||||
}
|
||||
child := context.WithValue(ctx, LanguageContextKey, "en-US")
|
||||
if !IsMCPOAuthNonInteractive(child) {
|
||||
t.Fatal("child context should inherit non-interactive flag")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLanguageFromContext(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user