@@ -113,7 +113,6 @@ func Test_UploadBatch(t *testing.T) {
113
113
mockSnykCodeClient .EXPECT ().ExtendBundle (gomock .Any (), "testBundleHash" , map [string ]deepcode.BundleFile {
114
114
"file" : {},
115
115
}, []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 )
117
116
118
117
mockSpan := mocks .NewMockSpan (ctrl )
119
118
mockSpan .EXPECT ().Context ().AnyTimes ()
@@ -130,11 +129,31 @@ func Test_UploadBatch(t *testing.T) {
130
129
require .NoError (t , err )
131
130
newHash := b .GetBundleHash ()
132
131
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
+
133
151
require .NoError (t , batchErr )
134
- err = b .UploadBatch (context .Background (), "testRequestId" , bundleFromRawContent )
152
+ oldHash := b .GetBundleHash ()
153
+ err := b .UploadBatch (context .Background (), "testRequestId" , bundleFromRawContent )
135
154
require .NoError (t , err )
136
- newestHash := b .GetBundleHash ()
137
- assert .NotEqual (t , newHash , newestHash )
155
+ newHash := b .GetBundleHash ()
156
+ assert .NotEqual (t , oldHash , newHash )
138
157
})
139
158
}
140
159
0 commit comments