adjust dir structures
Some checks failed
docker-release / build-and-push (push) Failing after 9m59s

This commit is contained in:
2025-11-14 15:02:33 +08:00
parent 960cf59a1d
commit 83bb6623e8
10 changed files with 344 additions and 9 deletions

38
main_test_helpers.go Normal file
View File

@@ -0,0 +1,38 @@
package main
import (
"bytes"
"testing"
)
// useBufferWriters swaps stdOut/stdErr with in-memory buffers for the duration
// of a test, allowing assertions on CLI output without polluting test logs.
func useBufferWriters(t *testing.T) {
t.Helper()
outBuf := &bytes.Buffer{}
errBuf := &bytes.Buffer{}
prevOut := stdOut
prevErr := stdErr
stdOut = outBuf
stdErr = errBuf
t.Cleanup(func() {
stdOut = prevOut
stdErr = prevErr
})
}
// stdOutBuffer returns the in-use stdout buffer when useBufferWriters is active.
func stdOutBuffer() *bytes.Buffer {
buf, _ := stdOut.(*bytes.Buffer)
return buf
}
// stdErrBuffer returns the in-use stderr buffer when useBufferWriters is active.
func stdErrBuffer() *bytes.Buffer {
buf, _ := stdErr.(*bytes.Buffer)
return buf
}