zyga@fyke:~/snapd/snap$ go test
----------------------------------------------------------------------
FAIL: info_test.go:528: infoSuite.TestRenamePlug
info_test.go:529:
snapInfo := snaptest.MockInfo(c, `name: core
plugs:
old:
interface: iface
slots:
old:
interface: iface
apps:
app:
hooks:
configure:
`, nil)
snaptest/snaptest.go:78:
c.Assert(err, check.IsNil)
... value *errors.errorString = &errors.errorString{s:"cannot have plug and slot with the same name: \"old\""} ("cannot have plug and slot with the same name: \"old\"")
OOPS: 144 passed, 1 FAILED
--- FAIL: Test (0.18s)
FAIL
exit status 1
FAIL github.com/snapcore/snapd/snap 0.186s
zyga@fyke:~/snapd/snap$ fg
vim info_test.go
[1]+ Zatrzymano vim info_test.go
zyga@fyke:~/snapd/snap$ git diff
diff --git a/snap/info_test.go b/snap/info_test.go
index 17f6f5c..b68e12a 100644
--- a/snap/info_test.go
+++ b/snap/info_test.go
@@ -530,6 +530,9 @@ func (s *infoSuite) TestRenamePlug(c *C) {
plugs:
old:
interface: iface
+slots:
+ old:
+ interface: iface
apps:
app:
hooks:
@@ -537,13 +540,16 @@ hooks:
`, nil)
c.Assert(snapInfo.Plugs["old"], Not(IsNil))
c.Assert(snapInfo.Plugs["old"].Name, Equals, "old")
+ c.Assert(snapInfo.Slots["old"], Not(IsNil))
+ c.Assert(snapInfo.Slots["old"].Name, Equals, "old")
c.Assert(snapInfo.Apps["app"].Plugs["old"], DeepEquals, snapInfo.Plugs["old"])
+ c.Assert(snapInfo.Apps["app"].Slots["old"], DeepEquals, snapInfo.Plugs["old"])
c.Assert(snapInfo.Hooks["configure"].Plugs["old"], DeepEquals, snapInfo.Plugs["old"])
// Rename the plug now.
snapInfo.RenamePlug("old", "new")
- // Check that there's no trace of the old name.
+ // Check that there's no trace of the old plug name.
c.Assert(snapInfo.Plugs["old"], IsNil)
c.Assert(snapInfo.Plugs["new"], Not(IsNil))
c.Assert(snapInfo.Plugs["new"].Name, Equals, "new")
@@ -551,4 +557,9 @@ hooks:
c.Assert(snapInfo.Apps["app"].Plugs["new"], DeepEquals, snapInfo.Plugs["new"])
c.Assert(snapInfo.Hooks["configure"].Plugs["old"], IsNil)
c.Assert(snapInfo.Hooks["configure"].Plugs["new"], DeepEquals, snapInfo.Plugs["new"])
+
+ // Check that slots with the old name are unaffected.
+ c.Assert(snapInfo.Slots["old"], Not(IsNil))
+ c.Assert(snapInfo.Slots["old"].Name, Equals, "old")
+ c.Assert(snapInfo.Apps["app"].Slots["old"], DeepEquals, snapInfo.Plugs["new"])
}