Skip to content

Commit 20a2e77

Browse files
committed
fix(cli): restore glyph theme after stateful tests
Co-Authored-By: Virgil <virgil@lethean.io>
1 parent 6b321fe commit 20a2e77

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

pkg/cli/ansi_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func TestUseUnicodeAndEmojiRestoreColorsAfterASCII(t *testing.T) {
112112
}
113113

114114
func TestRender_NilStyle_Good(t *testing.T) {
115+
restoreThemeAndColors(t)
115116
var s *AnsiStyle
116117
got := s.Render("test")
117118
if got != "test" {
@@ -120,6 +121,7 @@ func TestRender_NilStyle_Good(t *testing.T) {
120121
}
121122

122123
func TestAnsiStyle_Bad(t *testing.T) {
124+
restoreThemeAndColors(t)
123125
original := ColorEnabled()
124126
defer SetColorEnabled(original)
125127

@@ -140,6 +142,7 @@ func TestAnsiStyle_Bad(t *testing.T) {
140142
}
141143

142144
func TestAnsiStyle_Ugly(t *testing.T) {
145+
restoreThemeAndColors(t)
143146
original := ColorEnabled()
144147
defer SetColorEnabled(original)
145148

pkg/cli/check_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
)
77

88
func TestCheckBuilder_Good(t *testing.T) {
9+
restoreThemeAndColors(t)
910
UseASCII() // Deterministic output
1011

1112
checkResult := Check("database").Pass()
@@ -19,6 +20,7 @@ func TestCheckBuilder_Good(t *testing.T) {
1920
}
2021

2122
func TestCheckBuilder_Bad(t *testing.T) {
23+
restoreThemeAndColors(t)
2224
UseASCII()
2325

2426
checkResult := Check("lint").Fail()
@@ -41,6 +43,7 @@ func TestCheckBuilder_Bad(t *testing.T) {
4143
}
4244

4345
func TestCheckBuilder_Ugly(t *testing.T) {
46+
restoreThemeAndColors(t)
4447
UseASCII()
4548

4649
// Zero-value builder should not panic.

pkg/cli/glyph_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cli
33
import "testing"
44

55
func TestGlyph_Good(t *testing.T) {
6+
restoreThemeAndColors(t)
67
UseUnicode()
78
if Glyph(":check:") != "✓" {
89
t.Errorf("Expected ✓, got %s", Glyph(":check:"))
@@ -15,6 +16,7 @@ func TestGlyph_Good(t *testing.T) {
1516
}
1617

1718
func TestGlyph_Bad(t *testing.T) {
19+
restoreThemeAndColors(t)
1820
// Unknown shortcode returns the shortcode unchanged.
1921
UseUnicode()
2022
got := Glyph(":unknown:")
@@ -24,6 +26,7 @@ func TestGlyph_Bad(t *testing.T) {
2426
}
2527

2628
func TestGlyph_Ugly(t *testing.T) {
29+
restoreThemeAndColors(t)
2730
// Empty shortcode should not panic.
2831
got := Glyph("")
2932
if got != "" {
@@ -32,6 +35,7 @@ func TestGlyph_Ugly(t *testing.T) {
3235
}
3336

3437
func TestCompileGlyphs_Good(t *testing.T) {
38+
restoreThemeAndColors(t)
3539
UseUnicode()
3640
got := compileGlyphs("Status: :check:")
3741
if got != "Status: ✓" {
@@ -40,6 +44,7 @@ func TestCompileGlyphs_Good(t *testing.T) {
4044
}
4145

4246
func TestCompileGlyphs_Bad(t *testing.T) {
47+
restoreThemeAndColors(t)
4348
UseUnicode()
4449
// Text with no shortcodes should be returned as-is.
4550
got := compileGlyphs("no glyphs here")
@@ -49,6 +54,7 @@ func TestCompileGlyphs_Bad(t *testing.T) {
4954
}
5055

5156
func TestCompileGlyphs_Ugly(t *testing.T) {
57+
restoreThemeAndColors(t)
5258
// Empty string should not panic.
5359
got := compileGlyphs("")
5460
if got != "" {

pkg/cli/output_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func captureOutput(f func()) string {
2727
}
2828

2929
func TestSemanticOutput_Good(t *testing.T) {
30+
restoreThemeAndColors(t)
3031
UseASCII()
3132
SetColorEnabled(false)
3233
defer SetColorEnabled(true)
@@ -52,6 +53,7 @@ func TestSemanticOutput_Good(t *testing.T) {
5253
}
5354

5455
func TestSemanticOutput_Bad(t *testing.T) {
56+
restoreThemeAndColors(t)
5557
UseASCII()
5658
SetColorEnabled(false)
5759
defer SetColorEnabled(true)
@@ -74,6 +76,7 @@ func TestSemanticOutput_Bad(t *testing.T) {
7476
}
7577

7678
func TestSemanticOutput_Ugly(t *testing.T) {
79+
restoreThemeAndColors(t)
7780
UseASCII()
7881

7982
// Severity with various levels should not panic.

0 commit comments

Comments
 (0)