~james-page/ubuntu/wily/juju-core/mir-fixes

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/cmd/cmd_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-03-28 08:58:42 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20140328085842-cyzrgc120bdfxwj0
Tags: 1.17.7-0ubuntu1
* New upstream point release, including fixes for:
  - no debug log with all providers on Ubuntu 14.04 (LP: #1294776).
* d/control: Add cpu-checker dependency to juju-local (LP: #1297077).

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import (
7
7
        "bytes"
8
8
        "net/http"
 
9
        "os"
9
10
        "path/filepath"
10
11
 
11
12
        jc "github.com/juju/testing/checkers"
13
14
 
14
15
        "launchpad.net/juju-core/cmd"
15
16
        "launchpad.net/juju-core/testing"
 
17
        "launchpad.net/juju-core/utils"
16
18
)
17
19
 
18
20
type CmdSuite struct{}
22
24
func (s *CmdSuite) TestHttpTransport(c *gc.C) {
23
25
        transport := http.DefaultTransport.(*http.Transport)
24
26
        c.Assert(transport.DisableKeepAlives, jc.IsTrue)
 
27
        client := utils.GetNonValidatingHTTPClient()
 
28
        c.Assert(client.Transport.(*http.Transport).DisableKeepAlives, jc.IsTrue)
25
29
}
26
30
 
27
31
func (s *CmdSuite) TestContext(c *gc.C) {
111
115
        }
112
116
}
113
117
 
 
118
func (s *CmdSuite) TestDefaultContextReturnsErrorInDeletedDirectory(c *gc.C) {
 
119
        ctx := testing.Context(c)
 
120
        wd, err := os.Getwd()
 
121
        c.Assert(err, gc.IsNil)
 
122
        missing := ctx.Dir + "/missing"
 
123
        err = os.Mkdir(missing, 0700)
 
124
        c.Assert(err, gc.IsNil)
 
125
        err = os.Chdir(missing)
 
126
        c.Assert(err, gc.IsNil)
 
127
        defer os.Chdir(wd)
 
128
        err = os.Remove(missing)
 
129
        c.Assert(err, gc.IsNil)
 
130
        ctx, err = cmd.DefaultContext()
 
131
        c.Assert(err, gc.ErrorMatches, `getwd: no such file or directory`)
 
132
        c.Assert(ctx, gc.IsNil)
 
133
}
 
134
 
114
135
func (s *CmdSuite) TestCheckEmpty(c *gc.C) {
115
136
        c.Assert(cmd.CheckEmpty(nil), gc.IsNil)
116
137
        c.Assert(cmd.CheckEmpty([]string{"boo!"}), gc.ErrorMatches, `unrecognized args: \["boo!"\]`)