Skip to content

Commit b75803d

Browse files
chore: move test to a separate test
1 parent 3c72dcc commit b75803d

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

bundle/bundle_test.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ func Test_UploadBatch(t *testing.T) {
113113
mockSnykCodeClient.EXPECT().ExtendBundle(gomock.Any(), "testBundleHash", map[string]deepcode.BundleFile{
114114
"file": {},
115115
}, []string{}).Return("testBundleHash", []string{}, nil).Times(1)
116-
mockSnykCodeClient.EXPECT().ExtendBundle(gomock.Any(), "bundleWithMultipleFilesHash", bundleFilePartialMatcher{expectedKey: "hello", expectedContent: "world"}, []string{}).Return("bundleWithAllFilesHash", []string{}, nil).Times(1)
117116

118117
mockSpan := mocks.NewMockSpan(ctrl)
119118
mockSpan.EXPECT().Context().AnyTimes()
@@ -130,11 +129,31 @@ func Test_UploadBatch(t *testing.T) {
130129
require.NoError(t, err)
131130
newHash := b.GetBundleHash()
132131
assert.NotEqual(t, oldHash, newHash)
132+
})
133+
}
134+
135+
func Test_RawContentBatch(t *testing.T) {
136+
testLogger := zerolog.Nop()
137+
138+
t.Run("create a batch from raw content and upload the bundle", func(t *testing.T) {
139+
ctrl := gomock.NewController(t)
140+
mockSnykCodeClient := deepcodeMocks.NewMockDeepcodeClient(ctrl)
141+
mockSnykCodeClient.EXPECT().ExtendBundle(gomock.Any(), "testBundleHash", bundleFilePartialMatcher{expectedKey: "hello", expectedContent: "world"}, []string{}).Return("newBundleHash", []string{}, nil).Times(1)
142+
143+
mockSpan := mocks.NewMockSpan(ctrl)
144+
mockSpan.EXPECT().Context().AnyTimes()
145+
mockInstrumentor := mocks.NewMockInstrumentor(ctrl)
146+
mockInstrumentor.EXPECT().StartSpan(gomock.Any(), gomock.Any()).Return(mockSpan).AnyTimes()
147+
mockInstrumentor.EXPECT().Finish(gomock.Any()).AnyTimes()
148+
mockErrorReporter := mocks.NewMockErrorReporter(ctrl)
149+
b := bundle.NewBundle(mockSnykCodeClient, mockInstrumentor, mockErrorReporter, &testLogger, "testRootPath", "testBundleHash", map[string]deepcode.BundleFile{}, []string{}, []string{})
150+
133151
require.NoError(t, batchErr)
134-
err = b.UploadBatch(context.Background(), "testRequestId", bundleFromRawContent)
152+
oldHash := b.GetBundleHash()
153+
err := b.UploadBatch(context.Background(), "testRequestId", bundleFromRawContent)
135154
require.NoError(t, err)
136-
newestHash := b.GetBundleHash()
137-
assert.NotEqual(t, newHash, newestHash)
155+
newHash := b.GetBundleHash()
156+
assert.NotEqual(t, oldHash, newHash)
138157
})
139158
}
140159

0 commit comments

Comments
 (0)