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

Function TestPartsRequired

api-compose-object_test.go:38–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36)
37
38func TestPartsRequired(t *testing.T) {
39 testCases := []struct {
40 size int64
41 partSize int64
42 ref int64
43 }{
44 {0, 0, 0},
45 {1, 0, 1},
46 {gb5, 0, 1}, // 5 GiB / 5 GiB = 1 part
47 {gb5p1, 0, 2}, // 5 GiB + 1 byte needs 2 parts
48 {2 * gb5, 0, 2}, // 10 GiB / 5 GiB = 2 parts
49 {gb10p1, 0, 3}, // 10 GiB + 1 byte needs 3 parts
50 {gb10p2, 0, 3}, // 10 GiB + 2 bytes needs 3 parts
51 {gb10p1 + gb10p2, 0, 5}, // 20 GiB + 3 bytes needs 5 parts
52 {maxPartSize * 10, 0, 10}, // exactly 10 parts
53 // Custom part sizes
54 {gb5, gb1, 5}, // 5 GiB / 1 GiB = 5 parts
55 {gb5p1, gb1, 6}, // 5 GiB + 1 byte / 1 GiB = 6 parts
56 {2 * gb5, gb1, 10}, // 10 GiB / 1 GiB = 10 parts
57 // Legacy behavior with oldPartSize
58 {gb5, oldPartSize, 10}, // matches old behavior
59 {gb5p1, oldPartSize, 10}, // matches old behavior
60 {2 * gb5, oldPartSize, 20}, // matches old behavior
61 {gb10p1, oldPartSize, 20}, // matches old behavior
62 {gb10p2, oldPartSize, 20}, // matches old behavior
63 {gb10p1 + gb10p2, oldPartSize, 40}, // matches old behavior
64 {maxMultipartPutObjectSize, oldPartSize, 10000}, // matches old behavior
65 }
66
67 for i, testCase := range testCases {
68 res := partsRequired(testCase.size, testCase.partSize)
69 if res != testCase.ref {
70 t.Errorf("Test %d - output did not match with reference results, Expected %d, got %d", i+1, testCase.ref, res)
71 }
72 }
73}
74
75func TestCalculateEvenSplits(t *testing.T) {
76 testCases := []struct {

Callers

nothing calls this directly

Calls 1

partsRequiredFunction · 0.85

Tested by

no test coverage detected