func (s *brokenSuite) TestGuessAppsForBrokenServices(c *C) { touch(c, filepath.Join(dirs.SnapServicesDir, "snap.foo.foo.service")) touch(c, filepath.Join(dirs.SnapServicesDir, "snap.foo.bar.service")) info := &snap.Info{SuggestedName: "foo"} apps := snap.GuessAppsForBroken(info) c.Check(apps, HasLen, 2) c.Check(apps["foo"], DeepEquals, &snap.AppInfo{Snap: info, Name: "foo", Daemon: "simple"}) c.Check(apps["bar"], DeepEquals, &snap.AppInfo{Snap: info, Name: "bar", Daemon: "simple"}) }
func (s *brokenSuite) TestGuessAppsForBrokenBinaries(c *C) { touch(c, filepath.Join(dirs.SnapBinariesDir, "foo")) touch(c, filepath.Join(dirs.SnapBinariesDir, "foo.bar")) info := &snap.Info{SuggestedName: "foo"} apps := snap.GuessAppsForBroken(info) c.Check(apps, HasLen, 2) c.Check(apps["foo"], DeepEquals, &snap.AppInfo{Snap: info, Name: "foo"}) c.Check(apps["bar"], DeepEquals, &snap.AppInfo{Snap: info, Name: "bar"}) }
func readInfoAnyway(name string, si *snap.SideInfo) (*snap.Info, error) { info, err := snap.ReadInfo(name, si) if _, ok := err.(*snap.NotFoundError); ok { reason := fmt.Sprintf("cannot read snap %q: %s", name, err) info := &snap.Info{ SuggestedName: name, Broken: reason, } info.Apps = snap.GuessAppsForBroken(info) if si != nil { info.SideInfo = *si } return info, nil } return info, err }