Files
gibidify/cli/ui_terminal_test.go
Ismo Vuorinen 3f65b813bd feat: update go to 1.25, add permissions and envs (#49)
* chore(ci): update go to 1.25, add permissions and envs
* fix(ci): update pr-lint.yml
* chore: update go, fix linting
* fix: tests and linting
* fix(lint): lint fixes, renovate should now pass
* fix: updates, security upgrades
* chore: workflow updates, lint
* fix: more lint, checkmake, and other fixes
* fix: more lint, convert scripts to POSIX compliant
* fix: simplify codeql workflow
* tests: increase test coverage, fix found issues
* fix(lint): editorconfig checking, add to linters
* fix(lint): shellcheck, add to linters
* fix(lint): apply cr comment suggestions
* fix(ci): remove step-security/harden-runner
* fix(lint): remove duplication, apply cr fixes
* fix(ci): tests in CI/CD pipeline
* chore(lint): deduplication of strings
* fix(lint): apply cr comment suggestions
* fix(ci): actionlint
* fix(lint): apply cr comment suggestions
* chore: lint, add deps management
2025-10-10 12:14:42 +03:00

63 lines
1.1 KiB
Go

package cli
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsColorTerminal(t *testing.T) {
tests := []struct {
name string
env terminalEnvSetup
expected bool
}{
{
name: "dumb terminal",
env: envDumbTerminal,
expected: false,
},
{
name: "empty TERM",
env: envEmptyTerm,
expected: false,
},
{
name: "CI without GitHub Actions",
env: envCIWithoutGitHub,
expected: false,
},
{
name: "GitHub Actions",
env: envGitHubActions,
expected: true,
},
{
name: "NO_COLOR set",
env: envNoColor,
expected: false,
},
{
name: "FORCE_COLOR set",
env: envForceColor,
expected: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.env.apply(t)
result := isColorTerminal()
assert.Equal(t, tt.expected, result)
})
}
}
func TestIsInteractiveTerminal(t *testing.T) {
// This function checks if stderr is a terminal
// In test environment, it will typically return false
result := isInteractiveTerminal()
assert.False(t, result)
}