Permalink
Browse files

Update suites to use github.com/juju/testing.FakeHomeSuite.

  • Loading branch information...
1 parent 8be2415 commit c67e13c37948d5b3e41125c40425fccbee592452 @frankban frankban committed Jun 9, 2014
View
@@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
+ gitjujutesting "github.com/juju/testing"
gc "launchpad.net/gocheck"
"github.com/juju/juju/charm"
@@ -18,7 +19,7 @@ import (
)
type StoreSuite struct {
- testing.FakeHomeSuite
+ gitjujutesting.FakeHomeSuite
server *charmtesting.MockStore
store *charm.CharmStore
}
@@ -374,7 +375,7 @@ func (s *StoreSuite) TestCharmURL(c *gc.C) {
}
type LocalRepoSuite struct {
- testing.FakeHomeSuite
+ gitjujutesting.FakeHomeSuite
repo *charm.LocalRepository
seriesPath string
}
@@ -8,6 +8,7 @@ import (
"os"
"testing"
+ gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"launchpad.net/gnuflag"
gc "launchpad.net/gocheck"
@@ -40,7 +41,7 @@ func (s *EnvironmentCommandSuite) TestReadCurrentEnvironmentSet(c *gc.C) {
}
func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentNothingSet(c *gc.C) {
- envPath := coretesting.HomePath(".juju", "environments.yaml")
+ envPath := gitjujutesting.HomePath(".juju", "environments.yaml")
err := os.Remove(envPath)
c.Assert(err, gc.IsNil)
env, err := envcmd.GetDefaultEnvironment()
@@ -109,7 +110,7 @@ func (s *EnvironmentCommandSuite) TestEnvironCommandInit(c *gc.C) {
}
func (s *EnvironmentCommandSuite) TestEnvironCommandInitErrors(c *gc.C) {
- envPath := coretesting.HomePath(".juju", "environments.yaml")
+ envPath := gitjujutesting.HomePath(".juju", "environments.yaml")
err := os.Remove(envPath)
c.Assert(err, gc.IsNil)
cmd, _ := prepareEnvCommand(c, "")
View
@@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
+ gitjujutesting "github.com/juju/testing"
"github.com/juju/utils"
"launchpad.net/gnuflag"
gc "launchpad.net/gocheck"
@@ -17,7 +18,7 @@ import (
)
type FileVarSuite struct {
- testing.FakeHomeSuite
+ gitjujutesting.FakeHomeSuite
ctx *cmd.Context
ValidPath string
InvalidPath string // invalid path refers to a file which is not readable
@@ -10,6 +10,7 @@ import (
"github.com/juju/errors"
"github.com/juju/loggo"
+ gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "launchpad.net/gocheck"
@@ -675,7 +676,7 @@ func createToolsSource(c *gc.C, versions []version.Binary) string {
// resetJujuHome restores an new, clean Juju home environment without tools.
func resetJujuHome(c *gc.C) environs.Environ {
- jenvDir := coretesting.HomePath(".juju", "environments")
+ jenvDir := gitjujutesting.HomePath(".juju", "environments")
err := os.RemoveAll(jenvDir)
c.Assert(err, gc.IsNil)
coretesting.WriteEnvironments(c, envConfig)
View
@@ -9,6 +9,7 @@ import (
"os"
"strings"
+ gitjujutesting "github.com/juju/testing"
gc "launchpad.net/gocheck"
"github.com/juju/juju/cmd"
@@ -24,7 +25,7 @@ var _ = gc.Suite(&InitSuite{})
// The environments.yaml is created by default if it
// does not already exist.
func (*InitSuite) TestBoilerPlateEnvironment(c *gc.C) {
- envPath := testing.HomePath(".juju", "environments.yaml")
+ envPath := gitjujutesting.HomePath(".juju", "environments.yaml")
err := os.Remove(envPath)
c.Assert(err, gc.IsNil)
ctx := testing.Context(c)
@@ -33,7 +34,7 @@ func (*InitSuite) TestBoilerPlateEnvironment(c *gc.C) {
outStr := ctx.Stdout.(*bytes.Buffer).String()
strippedOut := strings.Replace(outStr, "\n", "", -1)
c.Check(strippedOut, gc.Matches, ".*A boilerplate environment configuration file has been written.*")
- environpath := testing.HomePath(".juju", "environments.yaml")
+ environpath := gitjujutesting.HomePath(".juju", "environments.yaml")
data, err := ioutil.ReadFile(environpath)
c.Assert(err, gc.IsNil)
strippedData := strings.Replace(string(data), "\n", "", -1)
@@ -43,7 +44,7 @@ func (*InitSuite) TestBoilerPlateEnvironment(c *gc.C) {
// The boilerplate is sent to stdout with --show, and the environments.yaml
// is not created.
func (*InitSuite) TestBoilerPlatePrinted(c *gc.C) {
- envPath := testing.HomePath(".juju", "environments.yaml")
+ envPath := gitjujutesting.HomePath(".juju", "environments.yaml")
err := os.Remove(envPath)
c.Assert(err, gc.IsNil)
ctx := testing.Context(c)
@@ -52,7 +53,7 @@ func (*InitSuite) TestBoilerPlatePrinted(c *gc.C) {
outStr := ctx.Stdout.(*bytes.Buffer).String()
strippedOut := strings.Replace(outStr, "\n", "", -1)
c.Check(strippedOut, gc.Matches, ".*# This is the Juju config file, which you can use.*")
- environpath := testing.HomePath(".juju", "environments.yaml")
+ environpath := gitjujutesting.HomePath(".juju", "environments.yaml")
_, err = ioutil.ReadFile(environpath)
c.Assert(err, gc.NotNil)
}
@@ -76,7 +77,7 @@ func (*InitSuite) TestExistingEnvironmentNotOverwritten(c *gc.C) {
errOut := ctx.Stderr.(*bytes.Buffer).String()
strippedOut := strings.Replace(errOut, "\n", "", -1)
c.Check(strippedOut, gc.Matches, ".*A juju environment configuration already exists.*")
- environpath := testing.HomePath(".juju", "environments.yaml")
+ environpath := gitjujutesting.HomePath(".juju", "environments.yaml")
data, err := ioutil.ReadFile(environpath)
c.Assert(err, gc.IsNil)
c.Assert(string(data), gc.Equals, existingEnv)
@@ -93,7 +94,7 @@ func (*InitSuite) TestExistingEnvironmentOverwritten(c *gc.C) {
stdOut := ctx.Stdout.(*bytes.Buffer).String()
strippedOut := strings.Replace(stdOut, "\n", "", -1)
c.Check(strippedOut, gc.Matches, ".*A boilerplate environment configuration file has been written.*")
- environpath := testing.HomePath(".juju", "environments.yaml")
+ environpath := gitjujutesting.HomePath(".juju", "environments.yaml")
data, err := ioutil.ReadFile(environpath)
c.Assert(err, gc.IsNil)
strippedData := strings.Replace(string(data), "\n", "", -1)
View
@@ -11,6 +11,7 @@ import (
"text/template"
"time"
+ gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "launchpad.net/gocheck"
@@ -27,7 +28,7 @@ var _ = gc.Suite(&PluginSuite{})
func (suite *PluginSuite) SetUpTest(c *gc.C) {
suite.FakeJujuHomeSuite.SetUpTest(c)
suite.oldPath = os.Getenv("PATH")
- os.Setenv("PATH", "/bin:"+testing.HomePath())
+ os.Setenv("PATH", "/bin:"+gitjujutesting.HomePath())
}
func (suite *PluginSuite) TearDownTest(c *gc.C) {
@@ -172,13 +173,13 @@ func (suite *PluginSuite) TestJujuEnvVars(c *gc.C) {
func (suite *PluginSuite) makePlugin(name string, perm os.FileMode) {
content := fmt.Sprintf("#!/bin/bash --norc\necho %s $*", name)
- filename := testing.HomePath(JujuPluginPrefix + name)
+ filename := gitjujutesting.HomePath(JujuPluginPrefix + name)
ioutil.WriteFile(filename, []byte(content), perm)
}
func (suite *PluginSuite) makeFailingPlugin(name string, exitStatus int) {
content := fmt.Sprintf("#!/bin/bash --norc\necho failing\nexit %d", exitStatus)
- filename := testing.HomePath(JujuPluginPrefix + name)
+ filename := gitjujutesting.HomePath(JujuPluginPrefix + name)
ioutil.WriteFile(filename, []byte(content), 0755)
}
@@ -225,13 +226,13 @@ func (suite *PluginSuite) makeFullPlugin(params PluginParams) {
// Create a new template and parse the plugin into it.
t := template.Must(template.New("plugin").Parse(pluginTemplate))
content := &bytes.Buffer{}
- filename := testing.HomePath("juju-" + params.Name)
+ filename := gitjujutesting.HomePath("juju-" + params.Name)
// Create the files in the temp dirs, so we don't pollute the working space
if params.Creates != "" {
- params.Creates = testing.HomePath(params.Creates)
+ params.Creates = gitjujutesting.HomePath(params.Creates)
}
if params.DependsOn != "" {
- params.DependsOn = testing.HomePath(params.DependsOn)
+ params.DependsOn = gitjujutesting.HomePath(params.DependsOn)
}
t.Execute(content, params)
ioutil.WriteFile(filename, content.Bytes(), 0755)
View
@@ -7,6 +7,7 @@ import (
"fmt"
"os"
+ gitjujutesting "github.com/juju/testing"
gc "launchpad.net/gocheck"
"github.com/juju/juju/bzr"
@@ -74,7 +75,7 @@ func (s *PublishSuite) TearDownSuite(c *gc.C) {
func (s *PublishSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
s.HTTPSuite.SetUpTest(c)
- s.FakeJujuHomeSuite.Home.AddFiles(c, testing.TestFile{
+ s.FakeJujuHomeSuite.Home.AddFiles(c, gitjujutesting.TestFile{
Name: ".bazaar/bazaar.conf",
Data: "[DEFAULT]\nemail = Test <testing@testing.invalid>\n",
})
View
@@ -6,6 +6,7 @@ package main
import (
"os"
+ gitjujutesting "github.com/juju/testing"
gc "launchpad.net/gocheck"
"github.com/juju/juju/cmd/envcmd"
@@ -20,7 +21,7 @@ type SwitchSimpleSuite struct {
var _ = gc.Suite(&SwitchSimpleSuite{})
func (*SwitchSimpleSuite) TestNoEnvironment(c *gc.C) {
- envPath := testing.HomePath(".juju", "environments.yaml")
+ envPath := gitjujutesting.HomePath(".juju", "environments.yaml")
err := os.Remove(envPath)
c.Assert(err, gc.IsNil)
_, err = testing.RunCommand(c, &SwitchCommand{})
@@ -42,7 +43,7 @@ func (*SwitchSimpleSuite) TestShowsDefault(c *gc.C) {
func (s *SwitchSimpleSuite) TestCurrentEnvironmentHasPrecidence(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
- s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".juju/current-environment", "fubar"})
+ s.FakeHomeSuite.Home.AddFiles(c, gitjujutesting.TestFile{".juju/current-environment", "fubar"})
context, err := testing.RunCommand(c, &SwitchCommand{})
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(context), gc.Equals, "fubar\n")
@@ -58,7 +59,7 @@ func (*SwitchSimpleSuite) TestShowsJujuEnv(c *gc.C) {
func (s *SwitchSimpleSuite) TestJujuEnvOverCurrentEnvironment(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
- s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".juju/current-environment", "fubar"})
+ s.FakeHomeSuite.Home.AddFiles(c, gitjujutesting.TestFile{".juju/current-environment", "fubar"})
os.Setenv("JUJU_ENV", "using-env")
context, err := testing.RunCommand(c, &SwitchCommand{})
c.Assert(err, gc.IsNil)
View
@@ -13,7 +13,7 @@ github.com/juju/loggo git 7e8c70b24b80b95b2284f09306aac0bd93588db8
github.com/juju/names git 8328a811f68114991579c14a6cc55fa10fbde600
github.com/juju/ratelimit git 0025ab75db6c6eaa4ffff0240c2c9e617ad1a0eb
github.com/juju/schema git 1887e824896b58a0f376fb8517b5eebb825828b8
-github.com/juju/testing git 6ddd2ffd711ddc941a84346ec464a1383cffa7f9
+github.com/juju/testing git 2d3d9a49bdbcd5c971a6d44672f62b1e30d89d96
github.com/juju/utils git 5e72dc2c1b8337e087cccea1ee33699fb607f7c5
labix.org/v2/mgo bzr gustavo@niemeyer.net-20140331185009-fhnh3xzfdpicup0j 273
launchpad.net/gnuflag bzr roger.peppe@canonical.com-20121003093437-zcyyw0lpvj2nifpk 12
@@ -11,6 +11,7 @@ import (
"github.com/juju/loggo"
"github.com/juju/schema"
+ gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/proxy"
gc "launchpad.net/gocheck"
@@ -725,7 +726,7 @@ type testFile struct {
}
func (s *ConfigSuite) TestConfig(c *gc.C) {
- files := []testing.TestFile{
+ files := []gitjujutesting.TestFile{
{".ssh/id_dsa.pub", "dsa"},
{".ssh/id_rsa.pub", "rsa\n"},
{".ssh/identity.pub", "identity"},
@@ -829,7 +830,7 @@ var emptyCertFilesTests = []configTest{
}
func (s *ConfigSuite) TestConfigEmptyCertFiles(c *gc.C) {
- files := []testing.TestFile{
+ files := []gitjujutesting.TestFile{
{".juju/my-name-cert.pem", ""},
{".juju/my-name-private-key.pem", ""},
}
@@ -841,7 +842,7 @@ func (s *ConfigSuite) TestConfigEmptyCertFiles(c *gc.C) {
}
}
-func (test configTest) check(c *gc.C, home *testing.FakeHome) {
+func (test configTest) check(c *gc.C, home *gitjujutesting.FakeHome) {
cfg, err := config.New(test.useDefaults, test.attrs)
if test.err != "" {
c.Check(cfg, gc.IsNil)
@@ -1038,7 +1039,7 @@ func (test configTest) assertDuration(c *gc.C, name string, actual time.Duration
}
func (s *ConfigSuite) TestConfigAttrs(c *gc.C) {
- // Normally this is handled by testing.FakeHome
+ // Normally this is handled by gitjujutesting.FakeHome
s.PatchEnvironment(osenv.JujuLoggingConfigEnvKey, "")
attrs := map[string]interface{}{
"type": "my-type",
@@ -1173,7 +1174,7 @@ var validationTests = []validationTest{{
}}
func (s *ConfigSuite) TestValidateChange(c *gc.C) {
- files := []testing.TestFile{
+ files := []gitjujutesting.TestFile{
{".ssh/identity.pub", "identity"},
}
s.FakeHomeSuite.Home.AddFiles(c, files...)
@@ -1192,7 +1193,7 @@ func (s *ConfigSuite) TestValidateChange(c *gc.C) {
}
func (s *ConfigSuite) addJujuFiles(c *gc.C) {
- s.FakeHomeSuite.Home.AddFiles(c, []testing.TestFile{
+ s.FakeHomeSuite.Home.AddFiles(c, []gitjujutesting.TestFile{
{".ssh/id_rsa.pub", "rsa\n"},
{".juju/myenv-cert.pem", caCert},
{".juju/myenv-private-key.pem", caKey},
@@ -1356,7 +1357,7 @@ func (s *ConfigSuite) TestAptProxyConfigMap(c *gc.C) {
func (s *ConfigSuite) TestGenerateStateServerCertAndKey(c *gc.C) {
// Add a cert.
- s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".ssh/id_rsa.pub", "rsa\n"})
+ s.FakeHomeSuite.Home.AddFiles(c, gitjujutesting.TestFile{".ssh/id_rsa.pub", "rsa\n"})
for _, test := range []struct {
configValues map[string]interface{}
View
@@ -11,6 +11,7 @@ import (
"strings"
"github.com/juju/loggo"
+ gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "launchpad.net/gocheck"
@@ -144,7 +145,7 @@ environments:
}
func (*suite) TestNoEnv(c *gc.C) {
- envPath := testing.HomePath(".juju", "environments.yaml")
+ envPath := gitjujutesting.HomePath(".juju", "environments.yaml")
err := os.Remove(envPath)
c.Assert(err, gc.IsNil)
es, err := environs.ReadEnvirons("")
@@ -215,7 +216,7 @@ environments:
`
outfile, err := environs.WriteEnvirons("", env)
c.Assert(err, gc.IsNil)
- path := testing.HomePath(".juju", "environments.yaml")
+ path := gitjujutesting.HomePath(".juju", "environments.yaml")
c.Assert(path, gc.Equals, outfile)
envs, err := environs.ReadEnvirons("")
@@ -228,7 +229,7 @@ environments:
func (s *suite) TestConfigPerm(c *gc.C) {
testing.MakeSampleJujuHome(c)
- path := testing.HomePath(".juju")
+ path := gitjujutesting.HomePath(".juju")
info, err := os.Lstat(path)
c.Assert(err, gc.IsNil)
oldPerm := info.Mode().Perm()
View
@@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
+ gitjujutesting "github.com/juju/testing"
"github.com/juju/utils"
gc "launchpad.net/gocheck"
"launchpad.net/goyaml"
@@ -48,7 +49,7 @@ type JujuConnSuite struct {
// /var/lib/juju: the use cases are completely non-overlapping, and any tests that
// really do need both to exist ought to be embedding distinct fixtures for the
// distinct environments.
- testing.FakeHomeSuite
+ gitjujutesting.FakeHomeSuite
testing.MgoSuite
envtesting.ToolsFixture
Conn *juju.Conn
View
@@ -14,6 +14,7 @@ import (
stdtesting "testing"
"time"
+ gitjujutesting "github.com/juju/testing"
"labix.org/v2/mgo/bson"
gc "launchpad.net/gocheck"
@@ -32,7 +33,7 @@ var _ = gc.Suite(&TrivialSuite{})
type StoreSuite struct {
testing.MgoSuite
testing.HTTPSuite
- testing.FakeHomeSuite
+ gitjujutesting.FakeHomeSuite
store *store.Store
}
Oops, something went wrong.

0 comments on commit c67e13c

Please sign in to comment.