@@ -33,6 +33,68 @@ describe('zipUtil', function () {
3333 sinon . restore ( )
3434 } )
3535
36+ it ( 'returns the proper size limit for zip' , function ( ) {
37+ assert . strictEqual (
38+ zipUtil . aboveByteLimit (
39+ CodeWhispererConstants . fileScanPayloadSizeLimitBytes + 1 ,
40+ CodeAnalysisScope . FILE_ON_DEMAND
41+ ) ,
42+ true
43+ )
44+
45+ assert . strictEqual (
46+ zipUtil . aboveByteLimit (
47+ CodeWhispererConstants . fileScanPayloadSizeLimitBytes + 1 ,
48+ CodeAnalysisScope . FILE_AUTO
49+ ) ,
50+ true
51+ )
52+
53+ assert . strictEqual (
54+ zipUtil . aboveByteLimit (
55+ CodeWhispererConstants . projectScanPayloadSizeLimitBytes + 1 ,
56+ CodeAnalysisScope . PROJECT
57+ ) ,
58+ true
59+ )
60+
61+ assert . strictEqual (
62+ zipUtil . aboveByteLimit (
63+ CodeWhispererConstants . fileScanPayloadSizeLimitBytes - 1 ,
64+ CodeAnalysisScope . FILE_ON_DEMAND
65+ ) ,
66+ false
67+ )
68+
69+ assert . strictEqual (
70+ zipUtil . aboveByteLimit (
71+ CodeWhispererConstants . fileScanPayloadSizeLimitBytes - 1 ,
72+ CodeAnalysisScope . FILE_AUTO
73+ ) ,
74+ false
75+ )
76+
77+ assert . strictEqual (
78+ zipUtil . aboveByteLimit (
79+ CodeWhispererConstants . projectScanPayloadSizeLimitBytes - 1 ,
80+ CodeAnalysisScope . PROJECT
81+ ) ,
82+ false
83+ )
84+ } )
85+
86+ it ( 'determines if adding file will exceed project byte limit' , function ( ) {
87+ assert . strictEqual (
88+ zipUtil . willReachProjectByteLimit ( CodeWhispererConstants . projectScanPayloadSizeLimitBytes , 1 ) ,
89+ true
90+ )
91+
92+ assert . strictEqual (
93+ zipUtil . willReachProjectByteLimit ( CodeWhispererConstants . projectScanPayloadSizeLimitBytes - 10 , 9 ) ,
94+ false
95+ )
96+ } )
97+
3698 it ( 'Should generate zip for file scan and return expected metadata' , async function ( ) {
3799 const zipMetadata = await zipUtil . generateZip ( vscode . Uri . file ( appCodePath ) , CodeAnalysisScope . FILE_AUTO )
38100 assert . strictEqual ( zipMetadata . lines , 49 )
@@ -45,7 +107,7 @@ describe('zipUtil', function () {
45107 } )
46108
47109 it ( 'Should throw error if payload size limit is reached for file scan' , async function ( ) {
48- sinon . stub ( zipUtil , 'reachSizeLimit ' ) . returns ( true )
110+ sinon . stub ( zipUtil , 'aboveByteLimit ' ) . returns ( true )
49111
50112 await assert . rejects (
51113 ( ) => zipUtil . generateZip ( vscode . Uri . file ( appCodePath ) , CodeAnalysisScope . FILE_AUTO ) ,
@@ -65,7 +127,7 @@ describe('zipUtil', function () {
65127 } )
66128
67129 it ( 'Should throw error if payload size limit is reached for project scan' , async function ( ) {
68- sinon . stub ( zipUtil , 'reachSizeLimit ' ) . returns ( true )
130+ sinon . stub ( zipUtil , 'aboveByteLimit ' ) . returns ( true )
69131
70132 await assert . rejects (
71133 ( ) => zipUtil . generateZip ( vscode . Uri . file ( appCodePath ) , CodeAnalysisScope . PROJECT ) ,
@@ -74,7 +136,7 @@ describe('zipUtil', function () {
74136 } )
75137
76138 it ( 'Should throw error if payload size limit will be reached for project scan' , async function ( ) {
77- sinon . stub ( zipUtil , 'willReachSizeLimit ' ) . returns ( true )
139+ sinon . stub ( zipUtil , 'aboveByteLimit ' ) . returns ( true )
78140
79141 await assert . rejects (
80142 ( ) => zipUtil . generateZip ( vscode . Uri . file ( appCodePath ) , CodeAnalysisScope . PROJECT ) ,
0 commit comments