Skip to content

Commit

Permalink
update some for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Feb 2, 2021
1 parent 4fd11c1 commit 0ae81bf
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions color_test.go
Expand Up @@ -63,24 +63,12 @@ func Example() {
func TestSet(t *testing.T) {
is := assert.New(t)

// set enable
Enable = true
fmt.Println("support color:", SupportColor())
fmt.Println("test color.Set() on OS:", runtime.GOOS)
if os.Getenv("GITHUB_ACTION") != "" {
fmt.Println("Skip run the tests on Github Action")
return
}

num, err := Set(FgGreen)
is.True(num > 0)
is.NoError(err)
_, err = Reset()
is.NoError(err)

// disable
old := Disable()
num, err = Set(FgGreen)
num, err := Set(FgGreen)
is.Nil(err)
is.Equal(0, num)

Expand All @@ -89,6 +77,19 @@ func TestSet(t *testing.T) {
is.Equal(0, num)
Enable = old // revert

// set enable
Enable = true
if os.Getenv("GITHUB_ACTION") != "" {
fmt.Println("Skip run the tests on Github Action")
return
}

num, err = Set(FgGreen)
is.True(num > 0)
is.NoError(err)
_, err = Reset()
is.NoError(err)

if runtime.GOOS == "windows" {
fd := uintptr(syscall.Stdout)
// if run test by goland, will return false
Expand Down

0 comments on commit 0ae81bf

Please sign in to comment.