fix(cli): restore glyph theme after stateful tests
Some checks failed
Security Scan / security (push) Has been cancelled

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 17:56:01 +00:00
parent 6b321fe5c9
commit 20a2e77e19
4 changed files with 15 additions and 0 deletions

View file

@ -112,6 +112,7 @@ func TestUseUnicodeAndEmojiRestoreColorsAfterASCII(t *testing.T) {
}
func TestRender_NilStyle_Good(t *testing.T) {
restoreThemeAndColors(t)
var s *AnsiStyle
got := s.Render("test")
if got != "test" {
@ -120,6 +121,7 @@ func TestRender_NilStyle_Good(t *testing.T) {
}
func TestAnsiStyle_Bad(t *testing.T) {
restoreThemeAndColors(t)
original := ColorEnabled()
defer SetColorEnabled(original)
@ -140,6 +142,7 @@ func TestAnsiStyle_Bad(t *testing.T) {
}
func TestAnsiStyle_Ugly(t *testing.T) {
restoreThemeAndColors(t)
original := ColorEnabled()
defer SetColorEnabled(original)

View file

@ -6,6 +6,7 @@ import (
)
func TestCheckBuilder_Good(t *testing.T) {
restoreThemeAndColors(t)
UseASCII() // Deterministic output
checkResult := Check("database").Pass()
@ -19,6 +20,7 @@ func TestCheckBuilder_Good(t *testing.T) {
}
func TestCheckBuilder_Bad(t *testing.T) {
restoreThemeAndColors(t)
UseASCII()
checkResult := Check("lint").Fail()
@ -41,6 +43,7 @@ func TestCheckBuilder_Bad(t *testing.T) {
}
func TestCheckBuilder_Ugly(t *testing.T) {
restoreThemeAndColors(t)
UseASCII()
// Zero-value builder should not panic.

View file

@ -3,6 +3,7 @@ package cli
import "testing"
func TestGlyph_Good(t *testing.T) {
restoreThemeAndColors(t)
UseUnicode()
if Glyph(":check:") != "✓" {
t.Errorf("Expected ✓, got %s", Glyph(":check:"))
@ -15,6 +16,7 @@ func TestGlyph_Good(t *testing.T) {
}
func TestGlyph_Bad(t *testing.T) {
restoreThemeAndColors(t)
// Unknown shortcode returns the shortcode unchanged.
UseUnicode()
got := Glyph(":unknown:")
@ -24,6 +26,7 @@ func TestGlyph_Bad(t *testing.T) {
}
func TestGlyph_Ugly(t *testing.T) {
restoreThemeAndColors(t)
// Empty shortcode should not panic.
got := Glyph("")
if got != "" {
@ -32,6 +35,7 @@ func TestGlyph_Ugly(t *testing.T) {
}
func TestCompileGlyphs_Good(t *testing.T) {
restoreThemeAndColors(t)
UseUnicode()
got := compileGlyphs("Status: :check:")
if got != "Status: ✓" {
@ -40,6 +44,7 @@ func TestCompileGlyphs_Good(t *testing.T) {
}
func TestCompileGlyphs_Bad(t *testing.T) {
restoreThemeAndColors(t)
UseUnicode()
// Text with no shortcodes should be returned as-is.
got := compileGlyphs("no glyphs here")
@ -49,6 +54,7 @@ func TestCompileGlyphs_Bad(t *testing.T) {
}
func TestCompileGlyphs_Ugly(t *testing.T) {
restoreThemeAndColors(t)
// Empty string should not panic.
got := compileGlyphs("")
if got != "" {

View file

@ -27,6 +27,7 @@ func captureOutput(f func()) string {
}
func TestSemanticOutput_Good(t *testing.T) {
restoreThemeAndColors(t)
UseASCII()
SetColorEnabled(false)
defer SetColorEnabled(true)
@ -52,6 +53,7 @@ func TestSemanticOutput_Good(t *testing.T) {
}
func TestSemanticOutput_Bad(t *testing.T) {
restoreThemeAndColors(t)
UseASCII()
SetColorEnabled(false)
defer SetColorEnabled(true)
@ -74,6 +76,7 @@ func TestSemanticOutput_Bad(t *testing.T) {
}
func TestSemanticOutput_Ugly(t *testing.T) {
restoreThemeAndColors(t)
UseASCII()
// Severity with various levels should not panic.