package logging

import (
	"bytes"
	"fmt"
	"os"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestWriteBootstrapErrorRedactsPathsAndParsedValues(t *testing.T) {
	var output bytes.Buffer
	WriteBootstrapError(&output, "initialize logging", fmt.Errorf("open log file: %w", &os.PathError{
		Op: "open", Path: "/private/workspace/agentteam.log", Err: os.ErrPermission,
	}))
	require.Equal(t, "agentteam bootstrap: initialize logging: open: permission denied\n", output.String())

	output.Reset()
	WriteBootstrapError(&output, "load config", fmt.Errorf(`parse AGENTTEAM_LOG_FILE_MAX_DAYS: strconv.Atoi: parsing "super-secret": invalid syntax`))
	require.Equal(t, "agentteam bootstrap: load config: parse AGENTTEAM_LOG_FILE_MAX_DAYS: strconv.Atoi: parsing \"<redacted>\": invalid syntax\n", output.String())
}
