Skip to content

Commit

Permalink
a/snapasserts: add tests for missing resource revision assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewphelpsj committed May 29, 2024
1 parent 2ea36d7 commit 3ad8649
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions asserts/snapasserts/snapasserts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,40 @@ func (s *snapassertsSuite) TestCrossCheckResource(c *C) {
c.Assert(err, IsNil)
}

func (s *snapassertsSuite) TestCrossCheckResourceMissingRevisionAssertion(c *C) {
s.testCrossCheckResourceMissingRevisionAssertion(c, "")
}

func (s *snapassertsSuite) TestCrossCheckResourceProvenanceMissingRevisionAssertion(c *C) {
s.testCrossCheckResourceMissingRevisionAssertion(c, "prov")
}

func (s *snapassertsSuite) testCrossCheckResourceMissingRevisionAssertion(c *C, provenance string) {
digest := makeDigest(12)
const size = uint64(1024)
const resourceName = "test-component"
const snapID = "snap-id-1"

Check failure on line 859 in asserts/snapasserts/snapasserts_test.go

View workflow job for this annotation

GitHub Actions / static-checks (latest/stable)

const `snapID` is unused (unused)

si := &snap.SideInfo{
SnapID: "snap-id-1",
Revision: snap.R(12),
}

csi := &snap.ComponentSideInfo{
Component: naming.NewComponentRef("snap", "test-component"),
Revision: snap.R(24),
}

err := snapasserts.CrossCheckResource(resourceName, digest, provenance, size, csi, si, nil, s.localDB)
c.Assert(err, NotNil)

var suffix string
if provenance != "" {
suffix = fmt.Sprintf(" provenance: %s", provenance)
}
c.Assert(err, ErrorMatches, fmt.Sprintf("internal error: cannot find pre-populated snap-resource-revision assertion for %q: %s%s", resourceName, digest, suffix))
}

func (s *snapassertsSuite) TestCrossCheckResourceProvenance(c *C) {
snapRev := snap.R(12)
const (
Expand Down

0 comments on commit 3ad8649

Please sign in to comment.