fix(cli): restore glyph theme after stateful tests
Some checks failed
Security Scan / security (push) Has been cancelled
Some checks failed
Security Scan / security (push) Has been cancelled
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
6b321fe5c9
commit
20a2e77e19
4 changed files with 15 additions and 0 deletions
|
|
@ -112,6 +112,7 @@ func TestUseUnicodeAndEmojiRestoreColorsAfterASCII(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRender_NilStyle_Good(t *testing.T) {
|
func TestRender_NilStyle_Good(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
var s *AnsiStyle
|
var s *AnsiStyle
|
||||||
got := s.Render("test")
|
got := s.Render("test")
|
||||||
if got != "test" {
|
if got != "test" {
|
||||||
|
|
@ -120,6 +121,7 @@ func TestRender_NilStyle_Good(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAnsiStyle_Bad(t *testing.T) {
|
func TestAnsiStyle_Bad(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
original := ColorEnabled()
|
original := ColorEnabled()
|
||||||
defer SetColorEnabled(original)
|
defer SetColorEnabled(original)
|
||||||
|
|
||||||
|
|
@ -140,6 +142,7 @@ func TestAnsiStyle_Bad(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAnsiStyle_Ugly(t *testing.T) {
|
func TestAnsiStyle_Ugly(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
original := ColorEnabled()
|
original := ColorEnabled()
|
||||||
defer SetColorEnabled(original)
|
defer SetColorEnabled(original)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCheckBuilder_Good(t *testing.T) {
|
func TestCheckBuilder_Good(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseASCII() // Deterministic output
|
UseASCII() // Deterministic output
|
||||||
|
|
||||||
checkResult := Check("database").Pass()
|
checkResult := Check("database").Pass()
|
||||||
|
|
@ -19,6 +20,7 @@ func TestCheckBuilder_Good(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckBuilder_Bad(t *testing.T) {
|
func TestCheckBuilder_Bad(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseASCII()
|
UseASCII()
|
||||||
|
|
||||||
checkResult := Check("lint").Fail()
|
checkResult := Check("lint").Fail()
|
||||||
|
|
@ -41,6 +43,7 @@ func TestCheckBuilder_Bad(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckBuilder_Ugly(t *testing.T) {
|
func TestCheckBuilder_Ugly(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseASCII()
|
UseASCII()
|
||||||
|
|
||||||
// Zero-value builder should not panic.
|
// Zero-value builder should not panic.
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package cli
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestGlyph_Good(t *testing.T) {
|
func TestGlyph_Good(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseUnicode()
|
UseUnicode()
|
||||||
if Glyph(":check:") != "✓" {
|
if Glyph(":check:") != "✓" {
|
||||||
t.Errorf("Expected ✓, got %s", 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) {
|
func TestGlyph_Bad(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
// Unknown shortcode returns the shortcode unchanged.
|
// Unknown shortcode returns the shortcode unchanged.
|
||||||
UseUnicode()
|
UseUnicode()
|
||||||
got := Glyph(":unknown:")
|
got := Glyph(":unknown:")
|
||||||
|
|
@ -24,6 +26,7 @@ func TestGlyph_Bad(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGlyph_Ugly(t *testing.T) {
|
func TestGlyph_Ugly(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
// Empty shortcode should not panic.
|
// Empty shortcode should not panic.
|
||||||
got := Glyph("")
|
got := Glyph("")
|
||||||
if got != "" {
|
if got != "" {
|
||||||
|
|
@ -32,6 +35,7 @@ func TestGlyph_Ugly(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompileGlyphs_Good(t *testing.T) {
|
func TestCompileGlyphs_Good(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseUnicode()
|
UseUnicode()
|
||||||
got := compileGlyphs("Status: :check:")
|
got := compileGlyphs("Status: :check:")
|
||||||
if got != "Status: ✓" {
|
if got != "Status: ✓" {
|
||||||
|
|
@ -40,6 +44,7 @@ func TestCompileGlyphs_Good(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompileGlyphs_Bad(t *testing.T) {
|
func TestCompileGlyphs_Bad(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseUnicode()
|
UseUnicode()
|
||||||
// Text with no shortcodes should be returned as-is.
|
// Text with no shortcodes should be returned as-is.
|
||||||
got := compileGlyphs("no glyphs here")
|
got := compileGlyphs("no glyphs here")
|
||||||
|
|
@ -49,6 +54,7 @@ func TestCompileGlyphs_Bad(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompileGlyphs_Ugly(t *testing.T) {
|
func TestCompileGlyphs_Ugly(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
// Empty string should not panic.
|
// Empty string should not panic.
|
||||||
got := compileGlyphs("")
|
got := compileGlyphs("")
|
||||||
if got != "" {
|
if got != "" {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ func captureOutput(f func()) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSemanticOutput_Good(t *testing.T) {
|
func TestSemanticOutput_Good(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseASCII()
|
UseASCII()
|
||||||
SetColorEnabled(false)
|
SetColorEnabled(false)
|
||||||
defer SetColorEnabled(true)
|
defer SetColorEnabled(true)
|
||||||
|
|
@ -52,6 +53,7 @@ func TestSemanticOutput_Good(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSemanticOutput_Bad(t *testing.T) {
|
func TestSemanticOutput_Bad(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseASCII()
|
UseASCII()
|
||||||
SetColorEnabled(false)
|
SetColorEnabled(false)
|
||||||
defer SetColorEnabled(true)
|
defer SetColorEnabled(true)
|
||||||
|
|
@ -74,6 +76,7 @@ func TestSemanticOutput_Bad(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSemanticOutput_Ugly(t *testing.T) {
|
func TestSemanticOutput_Ugly(t *testing.T) {
|
||||||
|
restoreThemeAndColors(t)
|
||||||
UseASCII()
|
UseASCII()
|
||||||
|
|
||||||
// Severity with various levels should not panic.
|
// Severity with various levels should not panic.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue