Files
wehub-resource-sync 48b3ccf279
gitleaks / gitleaks (push) Has been skipped
Test / test (ubuntu-latest) (push) Failing after 0s
Test / test (windows-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:12:29 +08:00

50 lines
793 B
Go

package report
import (
"bytes"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const expectPath = "../testdata/expected/"
const templatePath = "../testdata/report/"
func TestWriteStdout(t *testing.T) {
// Arrange
reporter := JsonReporter{}
buf := testWriter{
bytes.NewBuffer(nil),
}
findings := []Finding{
{
RuleID: "test-rule",
},
}
// Act
err := reporter.Write(buf, findings)
require.NoError(t, err)
got := buf.Bytes()
// Assert
assert.NotEmpty(t, got)
}
type testWriter struct {
*bytes.Buffer
}
func (t testWriter) Close() error {
return nil
}
// lineEndingReplacer normalizes CRLF to LF so tests pass on Windows.
var lineEndingReplacer = strings.NewReplacer(
"\\r\\n", "\\n",
"\r", "",
"\\r", "",
)