aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/output_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-27 19:53:43 +0900
committerOphestra <cat@gensokyo.uk>2025-09-27 19:55:37 +0900
commit802e6afa34de7f6124157153b0bde4ac25d7b363 (patch)
tree03e6b7601b182181a24285f0e0d68cf34329bac3 /container/output_test.go
parente906cae9ee0fd8b7b35c4a71af8ba86e60dd3c24 (diff)
container/output: move global output to msg
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/output_test.go')
-rw-r--r--container/output_test.go44
1 files changed, 6 insertions, 38 deletions
diff --git a/container/output_test.go b/container/output_test.go
index 54eba8fe..cfa8e0de 100644
--- a/container/output_test.go
+++ b/container/output_test.go
@@ -1,4 +1,4 @@
-package container
+package container_test
import (
"bytes"
@@ -8,10 +8,14 @@ import (
"syscall"
"testing"
+ "hakurei.app/container"
"hakurei.app/container/stub"
)
func TestSuspendable(t *testing.T) {
+ // copied from output.go
+ const suspendBufMax = 1 << 24
+
const (
// equivalent to len(want.pt)
nSpecialPtEquiv = -iota - 1
@@ -70,7 +74,7 @@ func TestSuspendable(t *testing.T) {
var dw expectWriter
- w := Suspendable{Downstream: &dw}
+ w := container.Suspendable{Downstream: &dw}
for _, tc := range testCases {
// these share the same writer, so cannot be subtests
t.Logf("writing step %q", tc.name)
@@ -149,39 +153,3 @@ func (w *expectWriter) Write(p []byte) (n int, err error) {
}
return
}
-
-func TestGetSetOutput(t *testing.T) {
- {
- out := GetOutput()
- t.Cleanup(func() { SetOutput(out) })
- }
-
- t.Run("default", func(t *testing.T) {
- SetOutput(new(stubOutput))
- if v, ok := GetOutput().(*DefaultMsg); ok {
- t.Fatalf("SetOutput: got unexpected output %#v", v)
- }
- SetOutput(nil)
- if _, ok := GetOutput().(*DefaultMsg); !ok {
- t.Fatalf("SetOutput: got unexpected output %#v", GetOutput())
- }
- })
-
- t.Run("stub", func(t *testing.T) {
- SetOutput(new(stubOutput))
- if _, ok := GetOutput().(*stubOutput); !ok {
- t.Fatalf("SetOutput: got unexpected output %#v", GetOutput())
- }
- })
-}
-
-type stubOutput struct {
- wrapF func(error, ...any) error
-}
-
-func (*stubOutput) IsVerbose() bool { panic("unreachable") }
-func (*stubOutput) Verbose(...any) { panic("unreachable") }
-func (*stubOutput) Verbosef(string, ...any) { panic("unreachable") }
-func (*stubOutput) Suspend() { panic("unreachable") }
-func (*stubOutput) Resume() bool { panic("unreachable") }
-func (*stubOutput) BeforeExit() { panic("unreachable") }