Merge lp:~sergiusens/goget-ubuntu-touch/1473333 into lp:goget-ubuntu-touch

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 218
Merged at revision: 219
Proposed branch: lp:~sergiusens/goget-ubuntu-touch/1473333
Merge into: lp:goget-ubuntu-touch
Diff against target: 75 lines (+50/-2)
2 files modified
ubuntu-device-flash/main.go (+4/-2)
ubuntu-device-flash/main_test.go (+46/-0)
To merge this branch: bzr merge lp:~sergiusens/goget-ubuntu-touch/1473333
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Leo Arias (community) Approve
Review via email: mp+277412@code.launchpad.net

Commit message

exit(1) on parse errors.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

The exit(1) works. I don't understand the test and when I try to run it I get:

./main_test.go:36: undefined: execute

Maybe I'm not running it properly?

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

On Fri, Nov 13, 2015 at 12:18 AM, Leo Arias <email address hidden> wrote:

> The exit(1) works. I don't understand the test and when I try to run it I
> get:
>
> ./main_test.go:36: undefined: execute
>
> Maybe I'm not running it properly?
>

Maybe I messed up ;-) Forgot to push something, should work now

Revision history for this message
Sergio Schvezov (sergiusens) :
Revision history for this message
Leo Arias (elopio) wrote :

+// ubuntu-device-flash - handles ubuntu disk images

You left here the comment from the other package.

And:

./main_test.go:23: imported and not used: "fmt"

review: Needs Fixing
218. By Sergio Schvezov

exit(1) on parse errors.

Revision history for this message
Leo Arias (elopio) wrote :

The test passes now.

review: Approve
Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu-device-flash/main.go'
2--- ubuntu-device-flash/main.go 2015-04-13 13:29:36 +0000
3+++ ubuntu-device-flash/main.go 2015-11-13 15:19:39 +0000
4@@ -43,8 +43,10 @@
5 var cacheDir = ubuntuimage.GetCacheDir()
6
7 func main() {
8- args := os.Args
9+ execute(os.Args)
10+}
11
12+func execute(args []string) {
13 if v := os.Getenv("MANPAGE"); v != "" {
14 manpagePath := "/tmp/ubuntu-device-flash.manpage"
15 w, err := os.Create(manpagePath)
16@@ -61,7 +63,7 @@
17
18 if _, err := parser.ParseArgs(args); err != nil {
19 fmt.Println(err)
20- return
21+ os.Exit(1)
22 }
23
24 }
25
26=== added file 'ubuntu-device-flash/main_test.go'
27--- ubuntu-device-flash/main_test.go 1970-01-01 00:00:00 +0000
28+++ ubuntu-device-flash/main_test.go 2015-11-13 15:19:39 +0000
29@@ -0,0 +1,46 @@
30+//
31+// ubuntu-device-flash - handles ubuntu disk images
32+//
33+// Copyright (c) 2015 Canonical Ltd.
34+//
35+// Written by Sergio Schvezov <sergio.schvezov@canonical.com>
36+//
37+package main
38+
39+// This program is free software: you can redistribute it and/or modify it
40+// under the terms of the GNU General Public License version 3, as published
41+// by the Free Software Foundation.
42+//
43+// This program is distributed in the hope that it will be useful, but
44+// WITHOUT ANY WARRANTY; without even the implied warranties of
45+// MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
46+// PURPOSE. See the GNU General Public License for more details.
47+//
48+// You should have received a copy of the GNU General Public License along
49+// with this program. If not, see <http://www.gnu.org/licenses/>.
50+
51+import (
52+ "os"
53+ "os/exec"
54+
55+ . "launchpad.net/gocheck"
56+)
57+
58+type ParserTestSuite struct{}
59+
60+var _ = Suite(&ParserTestSuite{})
61+
62+func (s *ParserTestSuite) TestExitStatusOnBadArgs(c *C) {
63+ if os.Getenv("BE_CRASHER") == "1" {
64+ execute([]string{"./ubuntu-device-flash", "--verbose", "core", "--output=/tmp/snappy.img", "--developer-mode"})
65+ return
66+ }
67+
68+ cmd := exec.Command(os.Args[0], "-gocheck.f", "ParserTestSuite.TestExitStatusOnBadArgs")
69+ cmd.Env = append(os.Environ(), "BE_CRASHER=1")
70+ out, err := cmd.CombinedOutput()
71+ e, ok := err.(*exec.ExitError)
72+ c.Assert(ok, Equals, true)
73+ c.Assert(e.Success(), Equals, false)
74+ c.Assert(string(out), Equals, "the required argument `release` was not provided\n")
75+}

Subscribers

People subscribed via source and target branches