File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ package cmd
2
+
3
+ import (
4
+ "bytes"
5
+ "os"
6
+ "strings"
7
+ "testing"
8
+
9
+ log "github.com/charmbracelet/log"
10
+ )
11
+
12
+ func TestNoColorLog (t * testing.T ) {
13
+ // Set the environment variable to disable color
14
+ // t.Setenv("NO_COLOR", "1")
15
+ t .Setenv ("ATMOS_LOGS_LEVEL" , "Debug" )
16
+ t .Setenv ("NO_COLOR" , "1" )
17
+ // Create a buffer to capture the output
18
+ var buf bytes.Buffer
19
+ log .SetOutput (& buf )
20
+
21
+ oldArgs := os .Args
22
+ defer func () {
23
+ os .Args = oldArgs
24
+ }()
25
+ // Set the arguments for the command
26
+ os .Args = []string {"atmos" , "about" }
27
+ // Execute the command
28
+ if err := Execute (); err != nil {
29
+ t .Fatalf ("Failed to execute command: %v" , err )
30
+ }
31
+ // Check if the output is without color
32
+ output := buf .String ()
33
+ if strings .Contains (output , "\033 [" ) {
34
+ t .Errorf ("Expected no color in output, but got: %s" , output )
35
+ }
36
+ t .Log (output , "output" )
37
+ }
You can’t perform that action at this time.
0 commit comments