MCPcopy Index your code
hub / github.com/aptly-dev/aptly / TestDownloadTryCompressionErrors

Method TestDownloadTryCompressionErrors

http/compression_test.go:133–159  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

131}
132
133func (s *CompressionSuite) TestDownloadTryCompressionErrors(c *C) {
134 d := NewFakeDownloader()
135 _, _, err := DownloadTryCompression(s.ctx, d, s.baseURL, "file", nil, true)
136 c.Assert(err, ErrorMatches, "unexpected request.*")
137
138 d = NewFakeDownloader()
139 d.ExpectError("http://example.com/file.bz2", &Error{Code: 404})
140 d.ExpectError("http://example.com/file.gz", &Error{Code: 404})
141 d.ExpectError("http://example.com/file.xz", &Error{Code: 404})
142 d.ExpectError("http://example.com/file", errors.New("403"))
143 _, _, err = DownloadTryCompression(s.ctx, d, s.baseURL, "file", nil, true)
144 c.Assert(err, ErrorMatches, "403")
145
146 d = NewFakeDownloader()
147 d.ExpectError("http://example.com/file.bz2", &Error{Code: 404})
148 d.ExpectError("http://example.com/file.gz", &Error{Code: 404})
149 d.ExpectError("http://example.com/file.xz", &Error{Code: 404})
150 d.ExpectResponse("http://example.com/file", rawData)
151 expectedChecksums := map[string]utils.ChecksumInfo{
152 "file.bz2": {Size: 7},
153 "file.gz": {Size: 7},
154 "file.xz": {Size: 7},
155 "file": {Size: 7},
156 }
157 _, _, err = DownloadTryCompression(s.ctx, d, s.baseURL, "file", expectedChecksums, false)
158 c.Assert(err, ErrorMatches, "checksums don't match.*")
159}

Callers

nothing calls this directly

Calls 4

ExpectErrorMethod · 0.95
ExpectResponseMethod · 0.95
NewFakeDownloaderFunction · 0.85
DownloadTryCompressionFunction · 0.85

Tested by

no test coverage detected