diff options
| author | Michael Vogt <mvo@ubuntu.com> | 2016-03-23 10:18:44 +0100 |
|---|---|---|
| committer | Michael Vogt <mvo@ubuntu.com> | 2016-03-23 10:18:44 +0100 |
| commit | 7b4539733cd06e83698555ff0796e4bbd54822ce (patch) | |
| tree | 43eb261450708001c4a6d76c9243479b9ff86c67 | |
| parent | 00b4148f5e5e1c32293cb023a41a1800df044805 (diff) | |
Unbreak snap install after d152db76 broke itbugfix/unbreak-snap-install
When channels got added, the cmdInstall/cmdRefresh types got no "Execute()" functions. This broke install/refresh.
| -rw-r--r-- | cmd/snap/cmd_snap_op.go | 40 | ||||
| -rw-r--r-- | cmd/snap/cmd_snap_op_test.go | 7 |
2 files changed, 35 insertions, 12 deletions
diff --git a/cmd/snap/cmd_snap_op.go b/cmd/snap/cmd_snap_op.go index 76d5425715..fd2cebcda4 100644 --- a/cmd/snap/cmd_snap_op.go +++ b/cmd/snap/cmd_snap_op.go @@ -93,6 +93,16 @@ type cmdOp struct { op func(*client.Client, string) (string, error) } +func (x *cmdOp) Execute([]string) error { + cli := Client() + uuid, err := x.op(cli, x.Positional.Snap) + if err != nil { + return err + } + + return wait(cli, uuid) +} + type cmdInstall struct { Channel string `long:"channel" description:"Install from this channel instead of the device's default"` Positional struct { @@ -100,6 +110,16 @@ type cmdInstall struct { } `positional-args:"yes" required:"yes"` } +func (x *cmdInstall) Execute([]string) error { + cli := Client() + uuid, err := cli.InstallSnap(x.Positional.Snap, x.Channel) + if err != nil { + return err + } + + return wait(cli, uuid) +} + type cmdRefresh struct { Channel string `long:"channel" description:"Refresh to the latest on this channel, and track this channel henceforth"` Positional struct { @@ -107,6 +127,16 @@ type cmdRefresh struct { } `positional-args:"yes" required:"yes"` } +func (x *cmdRefresh) Execute([]string) error { + cli := Client() + uuid, err := cli.RefreshSnap(x.Positional.Snap, x.Channel) + if err != nil { + return err + } + + return wait(cli, uuid) +} + func init() { for _, s := range []struct { name string @@ -127,13 +157,3 @@ func init() { addCommand("install", shortInstallHelp, longInstallHelp, func() interface{} { return &cmdInstall{} }) addCommand("refresh", shortRefreshHelp, longRefreshHelp, func() interface{} { return &cmdRefresh{} }) } - -func (x *cmdOp) Execute([]string) error { - cli := Client() - uuid, err := x.op(cli, x.Positional.Snap) - if err != nil { - return err - } - - return wait(cli, uuid) -} diff --git a/cmd/snap/cmd_snap_op_test.go b/cmd/snap/cmd_snap_op_test.go index bd08947479..783d6f6b01 100644 --- a/cmd/snap/cmd_snap_op_test.go +++ b/cmd/snap/cmd_snap_op_test.go @@ -36,7 +36,8 @@ func (s *SnapSuite) TestInstall(c *check.C) { c.Check(r.Method, check.Equals, "POST") c.Check(r.URL.Path, check.Equals, "/2.0/snaps/foo.bar") c.Check(DecodedRequestBody(c, r), check.DeepEquals, map[string]interface{}{ - "action": "install", + "action": "install", + "channel": "chan", }) w.WriteHeader(http.StatusAccepted) fmt.Fprintln(w, `{"type":"async", "result":{"resource": "/2.0/operations/42"}, "status_code": 202}`) @@ -54,9 +55,11 @@ func (s *SnapSuite) TestInstall(c *check.C) { n++ }) - rest, err := snap.Parser().ParseArgs([]string{"install", "foo.bar"}) + rest, err := snap.Parser().ParseArgs([]string{"install", "--channel", "chan", "foo.bar"}) c.Assert(err, check.IsNil) c.Assert(rest, check.DeepEquals, []string{}) c.Check(s.Stdout(), check.Equals, "") c.Check(s.Stderr(), check.Equals, "") + // ensure that the fake server api was actually hit + c.Check(n, check.Equals, 3) } |
