func (s *MprisInterfaceSuite) TestGetNameMissing(c *C) { const mockSnapYaml = `name: mpris-client version: 1.0 slots: mpris-slot: interface: mpris ` info := snaptest.MockInfo(c, mockSnapYaml, nil) slot := &interfaces.Slot{SlotInfo: info.Slots["mpris-slot"]} iface := &builtin.MprisInterface{} name, err := builtin.MprisGetName(iface, slot.Attrs) c.Assert(err, IsNil) c.Assert(name, Equals, "@{SNAP_NAME}") }
func (s *MprisInterfaceSuite) TestGetNameBadDot(c *C) { const mockSnapYaml = `name: mpris-client version: 1.0 slots: mpris-slot: interface: mpris name: foo.bar ` info := snaptest.MockInfo(c, mockSnapYaml, nil) slot := &interfaces.Slot{SlotInfo: info.Slots["mpris-slot"]} iface := &builtin.MprisInterface{} name, err := builtin.MprisGetName(iface, slot.Attrs) c.Assert(err, Not(IsNil)) c.Assert(err, ErrorMatches, "invalid name element: \"foo.bar\"") c.Assert(name, Equals, "") }
func (s *MprisInterfaceSuite) TestGetNameUnknownAttribute(c *C) { const mockSnapYaml = `name: mpris-client version: 1.0 slots: mpris-slot: interface: mpris unknown: foo ` info := snaptest.MockInfo(c, mockSnapYaml, nil) slot := &interfaces.Slot{SlotInfo: info.Slots["mpris-slot"]} iface := &builtin.MprisInterface{} name, err := builtin.MprisGetName(iface, slot.Attrs) c.Assert(err, Not(IsNil)) c.Assert(err, ErrorMatches, "unknown attribute 'unknown'") c.Assert(name, Equals, "") }