MCPcopy
hub / github.com/minio/minio-go / TestPartSize

Function TestPartSize

api_unit_test.go:112–178  ·  view source on GitHub ↗

Tests optimal part size.

(t *testing.T)

Source from the content-addressed store, hash-verified

110
111// Tests optimal part size.
112func TestPartSize(t *testing.T) {
113 _, _, _, err := OptimalPartInfo(5000000000000000000, minPartSize)
114 if err == nil {
115 t.Fatal("Error: should fail")
116 }
117 totalPartsCount, partSize, lastPartSize, err := OptimalPartInfo(5243928576, 5*1024*1024)
118 if err != nil {
119 t.Fatal("Error: ", err)
120 }
121 if totalPartsCount != 1001 {
122 t.Fatalf("Error: expecting total parts count of 1001: got %v instead", totalPartsCount)
123 }
124 if partSize != 5242880 {
125 t.Fatalf("Error: expecting part size of 5242880: got %v instead", partSize)
126 }
127 if lastPartSize != 1048576 {
128 t.Fatalf("Error: expecting last part size of 1048576: got %v instead", lastPartSize)
129 }
130 totalPartsCount, partSize, lastPartSize, err = OptimalPartInfo(5243928576, 0)
131 if err != nil {
132 t.Fatal("Error: ", err)
133 }
134 if totalPartsCount != 313 {
135 t.Fatalf("Error: expecting total parts count of 313: got %v instead", totalPartsCount)
136 }
137 if partSize != 16777216 {
138 t.Fatalf("Error: expecting part size of 16777216: got %v instead", partSize)
139 }
140 if lastPartSize != 9437184 {
141 t.Fatalf("Error: expecting last part size of 9437184: got %v instead", lastPartSize)
142 }
143 _, partSize, _, err = OptimalPartInfo(5000000000, minPartSize)
144 if err != nil {
145 t.Fatal("Error:", err)
146 }
147 if partSize != minPartSize {
148 t.Fatalf("Error: expecting part size of %v: got %v instead", minPartSize, partSize)
149 }
150 // if stream and using default optimal part size determined by sdk
151 totalPartsCount, partSize, lastPartSize, err = OptimalPartInfo(-1, 0)
152 if err != nil {
153 t.Fatal("Error:", err)
154 }
155 if totalPartsCount != 9930 {
156 t.Fatalf("Error: expecting total parts count of 9930: got %v instead", totalPartsCount)
157 }
158 if partSize != 553648128 {
159 t.Fatalf("Error: expecting part size of 553648128: got %v instead", partSize)
160 }
161 if lastPartSize != 385875968 {
162 t.Fatalf("Error: expecting last part size of 385875968: got %v instead", lastPartSize)
163 }
164
165 totalPartsCount, partSize, lastPartSize, err = OptimalPartInfo(-1, 64*1024*1024)
166 if err != nil {
167 t.Fatal("Error:", err)
168 }
169 if totalPartsCount != 10000 {

Callers

nothing calls this directly

Calls 1

OptimalPartInfoFunction · 0.85

Tested by

no test coverage detected