[chore] Remove broken test (#2748)

This wasn't actually testing the fix, which is more difficult to
orchestrate than is worth.

See: https://github.com/trufflesecurity/trufflehog/pull/2742
This commit is contained in:
Miccah 2024-04-25 11:27:17 -07:00 committed by GitHub
parent b430dae83e
commit fadf9c6286
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,13 +2,10 @@ package gitparse
import (
"bytes"
"io"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
bufferwriter "github.com/trufflesecurity/trufflehog/v3/pkg/writers/buffer_writer"
bufferedfilewriter "github.com/trufflesecurity/trufflehog/v3/pkg/writers/buffered_file_writer"
@ -2352,55 +2349,3 @@ index 2ee133b..12b4843 100644
+output = json
+region = us-east-2
`
type mockContentWriter struct{ counter int }
func newMockContentWriter() *mockContentWriter { return &mockContentWriter{counter: 1} }
func (m *mockContentWriter) ReadCloser() (io.ReadCloser, error) {
return io.NopCloser(bytes.NewReader([]byte{})), nil
}
func (m *mockContentWriter) CloseForWriting() error { return nil }
func (m *mockContentWriter) Len() int { return 0 }
func (m *mockContentWriter) String() (string, error) { return "", nil }
func (m *mockContentWriter) Write(p []byte) (n int, err error) { return len(p), nil }
func TestNewDiffContentWriterCreation(t *testing.T) {
testCases := []struct {
name string
opts []diffOption
expectedCount int
}{
{
name: "Without custom contentWriter",
expectedCount: 1,
},
{
name: "With custom contentWriter",
opts: []diffOption{withCustomContentWriter(newMockContentWriter())},
expectedCount: 1,
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
commit := new(Commit)
mockWriter := newMockContentWriter()
assert.NotNil(t, mockWriter, "Failed to create mockWriter")
diff := newDiff(commit, tc.opts...)
assert.NotNil(t, diff, "Failed to create diff")
assert.NotNil(t, diff.contentWriter, "Failed to create contentWriter")
assert.Equal(t, tc.expectedCount, mockWriter.counter, "Unexpected number of contentWriter creations")
})
}
}