Permalink
Browse files

add a test for lxd-support

  • Loading branch information...
1 parent 7331dcd commit 173152497e8e3e9d1966982ca4cd875376d94590 @jdstrand jdstrand committed Oct 14, 2016
Showing with 30 additions and 3 deletions.
  1. +30 −3 interfaces/builtin/basedeclaration_test.go
@@ -199,17 +199,44 @@ func (s *baseDeclSuite) TestAutoConnectionContent(c *C) {
}
func (s *baseDeclSuite) TestAutoConnectionLxdSupport(c *C) {
+ // by default, don't auto-connect
cand := s.connectCand(c, "lxd-support", "", "")
err := cand.CheckAutoConnect()
- c.Check(err, NotNil)
+ c.Check(err, IsNil)
+
+ // allow auto-connect to particular snap id
+ plugsSlots := `
+slots:
+ docker-support:
+ allow-auto-connection:
+ plug-snap-id:
+ - J60k4JY0HppjwOjW8dZdYc8obXKxujRu
+`
- // TODO: have the real snap-decl allow things and not the base-decl
- lxdDecl := s.mockSnapDecl(c, "lxd", "J60k4JY0HppjwOjW8dZdYc8obXKxujRu", "canonical", "")
+ lxdDecl := s.mockSnapDecl(c, "lxd", "J60k4JY0HppjwOjW8dZdYc8obXKxujRu", "canonical", plugsSlots)
cand.PlugSnapDeclaration = lxdDecl
err = cand.CheckAutoConnect()
c.Check(err, IsNil)
}
+// FIXME: this should fail but doesn't
+func (s *baseDeclSuite) TestAutoConnectionLxdSupportNoMatch(c *C) {
+ cand := s.connectCand(c, "lxd-support", "", "")
+ // don't allow auto-connect to non-matching snap id
+ plugsSlots := `
+slots:
+ docker-support:
+ allow-auto-connection:
+ plug-snap-id:
+ - nonmatchingnonmatchingnonmatchin
+`
+
+ lxdDecl := s.mockSnapDecl(c, "lxd", "J60k4JY0HppjwOjW8dZdYc8obXKxujRu", "canonical", plugsSlots)
+ cand.PlugSnapDeclaration = lxdDecl
+ err := cand.CheckAutoConnect()
+ c.Check(err, NotNil)
+}
+
// describe installation rules for slots succinctly for cross-checking,
// if an interface is not mentioned here a slot of its type can only
// be installed by a core snap (and this was taken care by

0 comments on commit 1731524

Please sign in to comment.