@@ -72,6 +72,37 @@ describe('S3DataStore', function () {
7272 assert . equal ( offset , size + incompleteSize )
7373 } )
7474
75+ it ( 'should process chunk size of exactly the min size' , async function ( ) {
76+ this . datastore . minPartSize = 1024 * 1024 * 5
77+ const store = this . datastore
78+ const size = 1024 * 1024 * 5
79+ const getIncompletePart = sinon . spy ( store , 'getIncompletePart' )
80+ const deleteIncompletePart = sinon . spy ( store , 'deleteIncompletePart' )
81+ const uploadIncompletePart = sinon . spy ( store , 'uploadIncompletePart' )
82+ const uploadPart = sinon . spy ( store , 'uploadPart' )
83+ const upload = new Upload ( {
84+ id : 'min-part-size-test' ,
85+ size : size + size ,
86+ offset : 0 ,
87+ } )
88+
89+ await store . create ( upload )
90+ const n1 = await store . write (
91+ Readable . from ( Buffer . alloc ( size ) ) ,
92+ upload . id ,
93+ upload . offset
94+ )
95+ assert . equal ( n1 , size )
96+ const n2 = await store . write ( Readable . from ( Buffer . alloc ( size ) ) , upload . id , n1 )
97+ assert . equal ( n2 , n1 + size )
98+ const { offset} = await store . getUpload ( upload . id )
99+ assert . equal ( getIncompletePart . called , true )
100+ assert . equal ( deleteIncompletePart . called , false )
101+ assert . equal ( uploadIncompletePart . called , false )
102+ assert . equal ( uploadPart . calledTwice , true )
103+ assert . equal ( offset , size + size )
104+ } )
105+
75106 shared . shouldHaveStoreMethods ( )
76107 shared . shouldCreateUploads ( )
77108 shared . shouldRemoveUploads ( ) // Termination extension
0 commit comments