~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/featuretests/package_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import (
7
7
        "flag"
8
8
        "runtime"
9
 
        stdtesting "testing"
 
9
        "testing"
10
10
 
 
11
        "github.com/juju/cmd"
 
12
        "github.com/juju/loggo"
 
13
        jc "github.com/juju/testing/checkers"
11
14
        gc "gopkg.in/check.v1"
12
15
 
 
16
        jujucmd "github.com/juju/juju/cmd/juju/commands"
13
17
        coretesting "github.com/juju/juju/testing"
14
18
)
15
19
 
16
20
var runFeatureTests = flag.Bool("featuretests", true, "Run long-running feature tests.")
17
21
 
18
22
func init() {
19
 
 
20
23
        flag.Parse()
21
24
 
22
25
        if *runFeatureTests == false {
39
42
        gc.Suite(&dumpLogsCommandSuite{})
40
43
        gc.Suite(&undertakerSuite{})
41
44
        gc.Suite(&upgradeSuite{})
 
45
        gc.Suite(&CmdRelationSuite{})
42
46
 
43
47
        // TODO (anastasiamac 2016-07-19) Bug#1603585
44
48
        // These tests cannot run on windows - they require a bootstrapped controller.
48
52
        }
49
53
}
50
54
 
51
 
func TestPackage(t *stdtesting.T) {
 
55
func TestPackage(t *testing.T) {
52
56
        coretesting.MgoTestPackage(t)
53
57
}
 
58
 
 
59
func runCommand(c *gc.C, args ...string) (*cmd.Context, error) {
 
60
        // Writers need to be reset, because
 
61
        // they are set globally in the juju/cmd package and will
 
62
        // return an error if we attempt to run two commands in the
 
63
        // same test.
 
64
        loggo.ResetWriters()
 
65
        ctx := coretesting.Context(c)
 
66
        command := jujucmd.NewJujuCommand(ctx)
 
67
        return coretesting.RunCommand(c, command, args...)
 
68
}
 
69
 
 
70
func runCommandExpectSuccess(c *gc.C, command string, args ...string) {
 
71
        _, err := runCommand(c, append([]string{command}, args...)...)
 
72
        c.Assert(err, jc.ErrorIsNil)
 
73
}
 
74
 
 
75
func runCommandExpectFailure(c *gc.C, command, expectedError string, args ...string) {
 
76
        context, err := runCommand(c, append([]string{command}, args...)...)
 
77
        c.Assert(err, gc.ErrorMatches, "cmd: error out silently")
 
78
        c.Assert(coretesting.Stderr(context), jc.Contains, expectedError)
 
79
}