Skip to content

Commit

Permalink
get tests back to passing
Browse files Browse the repository at this point in the history
  • Loading branch information
justone committed Mar 1, 2017
1 parent 73f29fe commit 87a9316
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
34 changes: 21 additions & 13 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (rdc *TestDockerClient) PullImage(fullImage string, output *os.File) error
return nil
}

func (rdc *TestDockerClient) BuildImage(name string, dockerfile string, output io.Writer) error {
func (rdc *TestDockerClient) BuildImage(name string, dockerfile string, key string, output io.Writer) error {
return nil
}

Expand Down Expand Up @@ -139,6 +139,18 @@ func (rdc *TestDockerClient) AddImage(image docker.APIImages) error {
return nil
}

func (rdc *TestDockerClient) ListVolumes() ([]docker.Volume, error) {
return []docker.Volume{}, nil
}

func (rdc *TestDockerClient) CreateVolume(cvo CreateVolumeOpts) error {
return nil
}

func (rdc *TestDockerClient) RemoveVolume(name string) error {
return nil
}

type TestSystemClient struct {
environments []string
sshArgs [][]string
Expand Down Expand Up @@ -168,7 +180,7 @@ func (tsc *TestSystemClient) GID() int {
return 1000
}

func (tsc *TestSystemClient) EnsureEnvironmentDir(envName string, keys SSHKey) (string, error) {
func (tsc *TestSystemClient) EnsureEnvironmentDir(envName string) (string, error) {
if err, ok := tsc.fails.failures["EnsureEnvironmentDir"]; ok {
return envName, err
}
Expand Down Expand Up @@ -228,8 +240,7 @@ func TestEnvironments(t *testing.T) {
},
},
)
key, _ := sc.EnsureSSHKey()
sc.EnsureEnvironmentDir("foo", key)
sc.EnsureEnvironmentDir("foo")

var envs map[string]Environment
var err error
Expand Down Expand Up @@ -400,8 +411,7 @@ func TestEnsureStopped(t *testing.T) {
},
},
)
key, _ := sc.EnsureSSHKey()
sc.EnsureEnvironmentDir("foo", key)
sc.EnsureEnvironmentDir("foo")

var env Environment
var err error
Expand Down Expand Up @@ -448,8 +458,7 @@ func TestEnsureRunning(t *testing.T) {
},
},
)
key, _ := sc.EnsureSSHKey()
sc.EnsureEnvironmentDir("foo", key)
sc.EnsureEnvironmentDir("foo")

var env Environment
var err error
Expand Down Expand Up @@ -477,7 +486,6 @@ func TestConnectEnvironment(t *testing.T) {
assert := assert.New(t)

sc := NewTestSystemClient()
key, _ := sc.EnsureSSHKey()

dc := NewTestDockerClient()
dc.AddContainer(
Expand All @@ -494,7 +502,7 @@ func TestConnectEnvironment(t *testing.T) {
},
},
)
sc.EnsureEnvironmentDir("foo", key)
sc.EnsureEnvironmentDir("foo")
dc.AddContainer(
docker.APIContainers{
ID: "qux",
Expand All @@ -507,7 +515,7 @@ func TestConnectEnvironment(t *testing.T) {
},
},
)
sc.EnsureEnvironmentDir("buz", key)
sc.EnsureEnvironmentDir("buz")
dc.AddContainer(
docker.APIContainers{
ID: "buz",
Expand All @@ -522,8 +530,8 @@ func TestConnectEnvironment(t *testing.T) {
},
},
)
sc.EnsureEnvironmentDir("qux", key)
sc.EnsureEnvironmentDir("oof", key)
sc.EnsureEnvironmentDir("qux")
sc.EnsureEnvironmentDir("oof")

var env Environment
var err error
Expand Down
18 changes: 1 addition & 17 deletions system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,7 @@ func TestDir(t *testing.T) {

sc, _ := NewSystemClientWithBase(base)

key, err := sc.EnsureSSHKey()
assert.Nil(err)

path, err := sc.EnsureEnvironmentDir("foo", key)
path, err := sc.EnsureEnvironmentDir("foo")
assert.Nil(err)
assert.NotEmpty(path)

sshPath := filepath.Join(path, ".ssh")
authorizedPath := filepath.Join(sshPath, "authorized_keys")
stat, err := os.Stat(sshPath)
assert.Nil(err)
assert.Equal(stat.Mode(), os.FileMode(0700|os.ModeDir))
stat, err = os.Stat(authorizedPath)
assert.Nil(err)
assert.Equal(stat.Mode(), os.FileMode(0700))

orig, _ := ioutil.ReadFile(key.publicPath)
copy, _ := ioutil.ReadFile(authorizedPath)
assert.Equal(orig, copy)
}

0 comments on commit 87a9316

Please sign in to comment.