mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
fix: Interactive pty identification for proxy mode (#174)
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package pty
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsInteractiveTerminal(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
ciEnv string
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "returns false when CI env is set to true",
|
||||
ciEnv: "true",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "returns false when CI env is set to TRUE (case insensitive)",
|
||||
ciEnv: "TRUE",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "returns false when CI env is set to True (mixed case)",
|
||||
ciEnv: "True",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "returns false in test runner (stdin/stdout are pipes)",
|
||||
ciEnv: "",
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if tt.ciEnv != "" {
|
||||
t.Setenv("CI", tt.ciEnv)
|
||||
} else {
|
||||
t.Setenv("CI", "")
|
||||
}
|
||||
|
||||
result := IsInteractiveTerminal()
|
||||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user