mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
43 lines
663 B
Go
43 lines
663 B
Go
package report
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
const expectPath = "../testdata/expected/"
|
|
const configPath = "../testdata/config/"
|
|
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
|
|
}
|