-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage_test.go
80 lines (68 loc) · 2.19 KB
/
package_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package featuretests
import (
"flag"
"runtime"
"testing"
"github.com/juju/cmd"
"github.com/juju/loggo"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
jujucmd "github.com/juju/juju/cmd/juju/commands"
coretesting "github.com/juju/juju/testing"
)
var runFeatureTests = flag.Bool("featuretests", true, "Run long-running feature tests.")
func init() {
flag.Parse()
if *runFeatureTests == false {
return
}
// Initialize all suites here.
gc.Suite(&annotationsSuite{})
gc.Suite(&CloudAPISuite{})
gc.Suite(&apiEnvironmentSuite{})
gc.Suite(&BakeryStorageSuite{})
gc.Suite(&blockSuite{})
gc.Suite(&cmdControllerSuite{})
gc.Suite(&cmdCredentialSuite{})
gc.Suite(&cmdJujuSuite{})
gc.Suite(&cmdLoginSuite{})
gc.Suite(&cmdModelSuite{})
gc.Suite(&cmdRegistrationSuite{})
gc.Suite(&cmdStorageSuite{})
gc.Suite(&cmdSubnetSuite{})
gc.Suite(&dblogSuite{})
gc.Suite(&dumpLogsCommandSuite{})
gc.Suite(&undertakerSuite{})
gc.Suite(&upgradeSuite{})
gc.Suite(&CmdRelationSuite{})
// TODO (anastasiamac 2016-07-19) Bug#1603585
// These tests cannot run on windows - they require a bootstrapped controller.
if runtime.GOOS == "linux" {
gc.Suite(&cloudImageMetadataSuite{})
gc.Suite(&cmdSpaceSuite{})
}
}
func TestPackage(t *testing.T) {
coretesting.MgoTestPackage(t)
}
func runCommand(c *gc.C, args ...string) (*cmd.Context, error) {
// Writers need to be reset, because
// they are set globally in the juju/cmd package and will
// return an error if we attempt to run two commands in the
// same test.
loggo.ResetWriters()
ctx := coretesting.Context(c)
command := jujucmd.NewJujuCommand(ctx)
return coretesting.RunCommand(c, command, args...)
}
func runCommandExpectSuccess(c *gc.C, command string, args ...string) {
_, err := runCommand(c, append([]string{command}, args...)...)
c.Assert(err, jc.ErrorIsNil)
}
func runCommandExpectFailure(c *gc.C, command, expectedError string, args ...string) {
context, err := runCommand(c, append([]string{command}, args...)...)
c.Assert(err, gc.ErrorMatches, "cmd: error out silently")
c.Assert(coretesting.Stderr(context), jc.Contains, expectedError)
}