MCPcopy
hub / github.com/rclone/rclone / testGzipEncoding

Method testGzipEncoding

backend/azureblob/azureblob_internal_test.go:172–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170}
171
172func (f *Fs) testGzipEncoding(t *testing.T) {
173 ctx := context.Background()
174 original := random.String(1000)
175 contents := gz(t, original)
176
177 item := fstest.NewItem("test-gzip", contents, fstest.Time("2001-05-06T04:05:06.499999999Z"))
178 metadata := fs.Metadata{
179 "content-encoding": "gzip",
180 "content-type": "text/plain",
181 }
182 obj := fstests.PutTestContentsMetadata(ctx, t, f, &item, true, contents, true, "text/html", metadata)
183 defer func() {
184 assert.NoError(t, obj.Remove(ctx))
185 }()
186 o := obj.(*Object)
187
188 // Test that the gzipped file we uploaded can be
189 // downloaded with and without decompression
190 checkDownload := func(wantContents string, wantSize int64, wantHash string) {
191 gotContents := fstests.ReadObject(ctx, t, o, -1)
192 assert.Equal(t, wantContents, gotContents)
193 assert.Equal(t, wantSize, o.Size())
194 gotHash, err := o.Hash(ctx, hash.MD5)
195 require.NoError(t, err)
196 assert.Equal(t, wantHash, gotHash)
197 }
198
199 t.Run("NoDecompress", func(t *testing.T) {
200 checkDownload(contents, int64(len(contents)), md5sum(t, contents))
201 })
202 t.Run("Decompress", func(t *testing.T) {
203 f.opt.Decompress = true
204 defer func() {
205 f.opt.Decompress = false
206 }()
207 checkDownload(original, -1, "")
208 })
209}
210
211func (f *Fs) InternalTest(t *testing.T) {
212 t.Run("Features", f.testFeatures)

Callers

nothing calls this directly

Calls 12

StringFunction · 0.92
NewItemFunction · 0.92
TimeFunction · 0.92
PutTestContentsMetadataFunction · 0.92
ReadObjectFunction · 0.92
gzFunction · 0.70
md5sumFunction · 0.70
RemoveMethod · 0.65
SizeMethod · 0.65
HashMethod · 0.65
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected