29 lines
768 B
Go
29 lines
768 B
Go
//go:build !unix
|
|
|
|
package promptdebug
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestPromptDebugWriterFailsClosedWithoutSecureTraversal(t *testing.T) {
|
|
root := filepath.Join(t.TempDir(), "debug")
|
|
writer, err := NewPromptDebugWriter(root)
|
|
if writer != nil || !errors.Is(err, ErrSecureCaptureUnsupported) {
|
|
t.Fatalf("NewPromptDebugWriter() = %#v, %v, want unsupported error", writer, err)
|
|
}
|
|
if _, statErr := os.Stat(root); !os.IsNotExist(statErr) {
|
|
t.Fatalf("prompt debug root was accessed: %v", statErr)
|
|
}
|
|
}
|
|
|
|
func TestDisabledPromptDebugWriterRemainsPortable(t *testing.T) {
|
|
writer, err := NewPromptDebugWriter("")
|
|
if err != nil || writer == nil || writer.Enabled() {
|
|
t.Fatalf("NewPromptDebugWriter(empty) = %#v, %v", writer, err)
|
|
}
|
|
}
|