mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-11-13 14:37:18 +00:00
Cover ReadLink's non-link and error paths
codecov/patch flagged the change at 75% of diff hit. The uncovered lines were the two the existing test could not reach: the fallthrough when no metadata key matches, and the HeadObject error return. Both are worth pinning regardless of the coverage gate. packageIndexByHash calls ReadLink on a path it has only just confirmed exists and treats an error as "leave it alone", so "this is not a link" and "I could not find out" have to stay distinguishable: the first is an empty string with a nil error, the second is an error. ReadLink goes to 100%.
This commit is contained in:
1 file changed
+18
@@ -437,6 +437,24 @@ func (s *PublishedStorageSuite) TestReadLinkMetadataKeyIsCaseInsensitive(c *C) {
|
||||
c.Check(link, Equals, "a/b")
|
||||
}
|
||||
|
||||
func (s *PublishedStorageSuite) TestReadLinkOnPlainObject(c *C) {
|
||||
// An object that is not a link has no SymLink metadata, and ReadLink
|
||||
// returns an empty string with a nil error rather than failing.
|
||||
// packageIndexByHash relies on that: it calls ReadLink on a path it has
|
||||
// only just confirmed exists, and treats an error as "leave it alone".
|
||||
s.PutFile(c, "a/plain", []byte("test"))
|
||||
|
||||
link, err := s.storage.ReadLink("a/plain")
|
||||
c.Check(err, IsNil)
|
||||
c.Check(link, Equals, "")
|
||||
|
||||
// A HeadObject that fails is an error, not an empty link. The two are
|
||||
// distinguishable so a caller can tell "this is not a link" from "I could
|
||||
// not find out".
|
||||
_, err = s.noSuchBucketStorage.ReadLink("a/plain")
|
||||
c.Check(err, NotNil)
|
||||
}
|
||||
|
||||
func (s *PublishedStorageSuite) TestFileExists(c *C) {
|
||||
s.PutFile(c, "a/b", []byte("test"))
|
||||
|
||||
|
||||
Reference in new issue
Block a user