Skip to content

Commit

Permalink
client,cmd: rename Interfaces (type) to Connections
Browse files Browse the repository at this point in the history
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Jul 26, 2017
1 parent 72fab62 commit 315ef4a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
12 changes: 6 additions & 6 deletions client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ type SlotRef struct {
Name string `json:"slot"`
}

// Interfaces contains information about all plugs, slots and their connections
type Interfaces struct {
// Connections contains information about all plugs, slots and their connections
type Connections struct {
Plugs []Plug `json:"plugs"`
Slots []Slot `json:"slots"`
}
Expand All @@ -83,10 +83,10 @@ type InterfaceAction struct {
}

// Connections returns all plugs, slots and their connections.
func (client *Client) Connections() (Interfaces, error) {
var ifaces Interfaces
_, err := client.doSync("GET", "/v2/interfaces", nil, nil, nil, &ifaces)
return ifaces, err
func (client *Client) Connections() (Connections, error) {
var conns Connections
_, err := client.doSync("GET", "/v2/interfaces", nil, nil, nil, &conns)
return conns, err
}

// InterfaceOptions represents opt-in elements include in responses.
Expand Down
4 changes: 2 additions & 2 deletions client/interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ func (cs *clientSuite) TestClientConnections(c *check.C) {
]
}
}`
interfaces, err := cs.cli.Connections()
conns, err := cs.cli.Connections()
c.Assert(err, check.IsNil)
c.Check(interfaces, check.DeepEquals, client.Interfaces{
c.Check(conns, check.DeepEquals, client.Connections{
Plugs: []client.Plug{
{
Snap: "canonical-pi2",
Expand Down
4 changes: 2 additions & 2 deletions cmd/snap/cmd_connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (s *SnapSuite) TestConnectImplicitPlugImplicitSlot(c *C) {
c.Assert(rest, DeepEquals, []string{})
}

var fortestingInterfaceList = client.Interfaces{
var fortestingConnectionList = client.Connections{
Slots: []client.Slot{
{
Snap: "core",
Expand Down Expand Up @@ -284,7 +284,7 @@ func (s *SnapSuite) TestConnectCompletion(c *C) {
c.Assert(r.Method, Equals, "GET")
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": fortestingInterfaceList,
"result": fortestingConnectionList,
})
default:
c.Fatalf("unexpected path %q", r.URL.Path)
Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/cmd_disconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (s *SnapSuite) TestDisconnectCompletion(c *C) {
c.Assert(r.Method, Equals, "GET")
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": fortestingInterfaceList,
"result": fortestingConnectionList,
})
default:
c.Fatalf("unexpected path %q", r.URL.Path)
Expand Down
50 changes: 25 additions & 25 deletions cmd/snap/cmd_interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
. "github.com/snapcore/snapd/cmd/snap"
)

func (s *SnapSuite) TestInterfacesHelp(c *C) {
func (s *SnapSuite) TestConnectionsHelp(c *C) {
msg := `Usage:
snap.test [OPTIONS] interfaces [interfaces-OPTIONS] [<snap>:<slot or plug>]
Expand Down Expand Up @@ -70,7 +70,7 @@ Help Options:
c.Assert(rest, DeepEquals, []string{})
}

func (s *SnapSuite) TestInterfacesZeroSlotsOnePlug(c *C) {
func (s *SnapSuite) TestConnectionsZeroSlotsOnePlug(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -79,7 +79,7 @@ func (s *SnapSuite) TestInterfacesZeroSlotsOnePlug(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Plugs: []client.Plug{
{
Snap: "keyboard-lights",
Expand All @@ -99,7 +99,7 @@ func (s *SnapSuite) TestInterfacesZeroSlotsOnePlug(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesZeroPlugsOneSlot(c *C) {
func (s *SnapSuite) TestConnectionsZeroPlugsOneSlot(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -108,7 +108,7 @@ func (s *SnapSuite) TestInterfacesZeroPlugsOneSlot(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "canonical-pi2",
Expand All @@ -130,7 +130,7 @@ func (s *SnapSuite) TestInterfacesZeroPlugsOneSlot(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesOneSlotOnePlug(c *C) {
func (s *SnapSuite) TestConnectionsOneSlotOnePlug(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -139,7 +139,7 @@ func (s *SnapSuite) TestInterfacesOneSlotOnePlug(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "canonical-pi2",
Expand Down Expand Up @@ -197,7 +197,7 @@ func (s *SnapSuite) TestInterfacesOneSlotOnePlug(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesTwoPlugs(c *C) {
func (s *SnapSuite) TestConnectionsTwoPlugs(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -206,7 +206,7 @@ func (s *SnapSuite) TestInterfacesTwoPlugs(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "canonical-pi2",
Expand Down Expand Up @@ -238,7 +238,7 @@ func (s *SnapSuite) TestInterfacesTwoPlugs(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesPlugsWithCommonName(c *C) {
func (s *SnapSuite) TestConnectionsPlugsWithCommonName(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -247,7 +247,7 @@ func (s *SnapSuite) TestInterfacesPlugsWithCommonName(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "canonical-pi2",
Expand Down Expand Up @@ -305,7 +305,7 @@ func (s *SnapSuite) TestInterfacesPlugsWithCommonName(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesOsSnapSlots(c *C) {
func (s *SnapSuite) TestConnectionsOsSnapSlots(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -314,7 +314,7 @@ func (s *SnapSuite) TestInterfacesOsSnapSlots(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "core",
Expand Down Expand Up @@ -372,7 +372,7 @@ func (s *SnapSuite) TestInterfacesOsSnapSlots(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesTwoSlotsAndFiltering(c *C) {
func (s *SnapSuite) TestConnectionsTwoSlotsAndFiltering(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -381,7 +381,7 @@ func (s *SnapSuite) TestInterfacesTwoSlotsAndFiltering(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "canonical-pi2",
Expand Down Expand Up @@ -421,7 +421,7 @@ func (s *SnapSuite) TestInterfacesTwoSlotsAndFiltering(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesOfSpecificSnap(c *C) {
func (s *SnapSuite) TestConnectionsOfSpecificSnap(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -430,7 +430,7 @@ func (s *SnapSuite) TestInterfacesOfSpecificSnap(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "cheese",
Expand Down Expand Up @@ -465,7 +465,7 @@ func (s *SnapSuite) TestInterfacesOfSpecificSnap(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesOfSpecificSnapAndSlot(c *C) {
func (s *SnapSuite) TestConnectionsOfSpecificSnapAndSlot(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -474,7 +474,7 @@ func (s *SnapSuite) TestInterfacesOfSpecificSnapAndSlot(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "cheese",
Expand Down Expand Up @@ -508,7 +508,7 @@ func (s *SnapSuite) TestInterfacesOfSpecificSnapAndSlot(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesNothingAtAll(c *C) {
func (s *SnapSuite) TestConnectionsNothingAtAll(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -517,7 +517,7 @@ func (s *SnapSuite) TestInterfacesNothingAtAll(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{},
"result": client.Connections{},
})
})
rest, err := Parser().ParseArgs([]string{"interfaces"})
Expand All @@ -529,7 +529,7 @@ func (s *SnapSuite) TestInterfacesNothingAtAll(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesOfSpecificType(c *C) {
func (s *SnapSuite) TestConnectionsOfSpecificType(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "GET")
c.Check(r.URL.Path, Equals, "/v2/interfaces")
Expand All @@ -538,7 +538,7 @@ func (s *SnapSuite) TestInterfacesOfSpecificType(c *C) {
c.Check(body, DeepEquals, []byte{})
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": client.Interfaces{
"result": client.Connections{
Slots: []client.Slot{
{
Snap: "cheese",
Expand Down Expand Up @@ -574,14 +574,14 @@ func (s *SnapSuite) TestInterfacesOfSpecificType(c *C) {
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestInterfacesCompletion(c *C) {
func (s *SnapSuite) TestConnectionsCompletion(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/v2/interfaces":
c.Assert(r.Method, Equals, "GET")
EncodeResponseBody(c, w, map[string]interface{}{
"type": "sync",
"result": fortestingInterfaceList,
"result": fortestingConnectionList,
})
default:
c.Fatalf("unexpected path %q", r.URL.Path)
Expand Down

0 comments on commit 315ef4a

Please sign in to comment.