package s3 import "testing" // TestUploadPartSize checks that an upload too large for 10,000 parts of the // configured size gets parts just large enough to fit in 10,000. func TestUploadPartSize(t *testing.T) { t.Parallel() const mib = 1024 * 1024 tests := []struct { name string configured int64 size int64 want int64 }{ { name: "an upload that fits keeps the configured size", configured: 5 * mib, size: 10 * 1024 * mib, want: 5 * mib, }, { name: "exactly 10,000 parts keeps the configured size", configured: 6 * mib, size: 10_000 * 6 * mib, want: 6 * mib, }, { name: "one byte more than 10,000 parts adds a byte to each", configured: 6 * mib, size: 10_000*6*mib + 1, want: 6*mib + 1, }, { name: "zero means the SDK default of 5MiB", configured: 0, size: 1, want: 5 * mib, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Parallel() got := uploadPartSize(tt.configured, tt.size) if got != tt.want { t.Errorf("uploadPartSize(%d, %d) = %d, want %d", tt.configured, tt.size, got, tt.want) } }) } }