From 55c399a644fd417f227681c6d82177ac6571bc70 Mon Sep 17 00:00:00 2001 From: Andrew Phelps Date: Wed, 17 Apr 2024 11:01:12 -0400 Subject: [PATCH] interfaces: add test that checks when app set is made with components from the wrong snap --- interfaces/snap_app_set_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/interfaces/snap_app_set_test.go b/interfaces/snap_app_set_test.go index 2ee867e640c7..c49f4cc9de8c 100644 --- a/interfaces/snap_app_set_test.go +++ b/interfaces/snap_app_set_test.go @@ -4,6 +4,7 @@ import ( "github.com/snapcore/snapd/dirs" "github.com/snapcore/snapd/interfaces" "github.com/snapcore/snapd/snap" + "github.com/snapcore/snapd/snap/naming" "github.com/snapcore/snapd/snap/snaptest" "github.com/snapcore/snapd/testutil" . "gopkg.in/check.v1" @@ -261,6 +262,14 @@ func (s *snapAppSetSuite) TestInstanceName(c *C) { c.Check(set.InstanceName(), Equals, "test-snap") } +func (s *snapAppSetSuite) TestNewAppSetWithWrongComponent(c *C) { + info := snaptest.MockInfo(c, yaml, nil) + _, err := interfaces.NewSnapAppSet(info, []*snap.ComponentInfo{{ + Component: naming.NewComponentRef("other-name", "comp"), + }}) + c.Assert(err, ErrorMatches, `internal error: snap "test-snap" does not own component "other-name\+comp"`) +} + func appsInMap(apps map[string]*snap.AppInfo) []*snap.AppInfo { result := make([]*snap.AppInfo, 0, len(apps)) for _, app := range apps {