Files
cunicu/pkg/tty/tty_test.go
Steffen Vogel 3bee839348 fix: Update copyright years
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
2025-01-01 22:45:39 +01:00

46 lines
920 B
Go

// SPDX-FileCopyrightText: 2023-2025 Steffen Vogel <post@steffenvogel.de>
// SPDX-License-Identifier: Apache-2.0
package tty_test
import (
"os"
"path/filepath"
"testing"
"cunicu.li/cunicu/pkg/tty"
"cunicu.li/cunicu/test"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestSuite(t *testing.T) {
test.SetupLogging()
RegisterFailHandler(Fail)
RunSpecs(t, "TTY Suite")
}
var _ = Context("IsATTY", func() {
if test.IsCI() {
It("is false in CI runners", func() {
Expect(tty.IsATTY(os.Stdout)).To(BeFalse())
})
} else {
It("is true outside CI runners", func() {
Expect(tty.IsATTY(os.Stdout)).To(BeTrue())
})
}
It("is false on files", func() {
fn := filepath.Join(GinkgoT().TempDir(), "file")
f, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY, 0o600)
Expect(err).To(Succeed())
Expect(tty.IsATTY(f)).To(BeFalse())
err = f.Close()
Expect(err).To(Succeed())
})
})