Skip to content

Commit

Permalink
asserts: do not require revision when setting component as invalid (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewphelpsj authored Sep 23, 2024
1 parent aa9513c commit b0e2fe5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion asserts/validation_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func checkValidationSetComponent(compName string, comp map[string]interface{}, s
return ValidationSetComponent{}, fmt.Errorf("cannot specify component revision %s at the same time as stating its presence is invalid", what)
}

if snapRevision != 0 && revision == 0 {
if snapRevision != 0 && revision == 0 && presence != PresenceInvalid {
return ValidationSetComponent{}, fmt.Errorf("must specify revision %s since its associated snap specifies a revision", what)
}

Expand Down
4 changes: 4 additions & 0 deletions asserts/validation_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (vss *validationSetSuite) TestSnapComponents(c *C) {
with-revision:
revision: 10
presence: required
invalid-without-revision: invalid
-
name: foo-linux
id: foolinuxidididididididididididid
Expand All @@ -208,6 +209,9 @@ func (vss *validationSetSuite) TestSnapComponents(c *C) {
Presence: asserts.PresenceRequired,
Revision: 10,
},
"invalid-without-revision": {
Presence: asserts.PresenceInvalid,
},
})
c.Check(snaps[1].Components, DeepEquals, map[string]asserts.ValidationSetComponent{
"string-only": {
Expand Down

0 comments on commit b0e2fe5

Please sign in to comment.