Skip to content

Commit

Permalink
Update tests for new script paths
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Jun 7, 2018
1 parent 5875d53 commit b09272c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ key to enable continuous deployment.`)

// DaemonUp brings the daemon up on the remote instance.
func (c *Client) DaemonUp(daemonVersion, host, daemonPort string) error {
scriptBytes, err := internal.Asset("client/bootstrap/daemon-up.sh")
scriptBytes, err := internal.Asset("client/scripts/daemon-up.sh")
if err != nil {
return err
}
Expand All @@ -121,7 +121,7 @@ func (c *Client) DaemonUp(daemonVersion, host, daemonPort string) error {

// DaemonDown brings the daemon down on the remote instance
func (c *Client) DaemonDown() error {
scriptBytes, err := internal.Asset("client/bootstrap/daemon-down.sh")
scriptBytes, err := internal.Asset("client/scripts/daemon-down.sh")
if err != nil {
return err
}
Expand Down
19 changes: 9 additions & 10 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,19 @@ func TestGetNewClient(t *testing.T) {
func TestInstallDocker(t *testing.T) {
session := &mockSSHRunner{}
client := getIntegrationClient(session)
script, err := ioutil.ReadFile("bootstrap/docker.sh")
script, err := ioutil.ReadFile("scripts/docker.sh")
assert.Nil(t, err)

// Make sure the right command is run.
client.installDocker(session)
err = client.installDocker(session)
assert.Nil(t, err)
assert.Equal(t, string(script), session.Calls[0])
}

func TestDaemonUp(t *testing.T) {
session := &mockSSHRunner{}
client := getIntegrationClient(session)
script, err := ioutil.ReadFile("bootstrap/daemon-up.sh")
script, err := ioutil.ReadFile("scripts/daemon-up.sh")
assert.Nil(t, err)
actualCommand := fmt.Sprintf(string(script), "latest", "4303", "0.0.0.0")

Expand All @@ -137,12 +138,10 @@ func TestDaemonUp(t *testing.T) {
func TestKeyGen(t *testing.T) {
session := &mockSSHRunner{}
remote := getIntegrationClient(session)
script, err := ioutil.ReadFile("bootstrap/token.sh")
script, err := ioutil.ReadFile("scripts/token.sh")
assert.Nil(t, err)
tokenScript := fmt.Sprintf(string(script), "test")

// Make sure the right command is run.

// Make sure the right command is run.
_, err = remote.getDaemonAPIToken(session, "test")
assert.Nil(t, err)
Expand All @@ -153,17 +152,17 @@ func TestBootstrap(t *testing.T) {
session := &mockSSHRunner{}
client := getIntegrationClient(session)

dockerScript, err := ioutil.ReadFile("bootstrap/docker.sh")
dockerScript, err := ioutil.ReadFile("scripts/docker.sh")
assert.Nil(t, err)

keyScript, err := ioutil.ReadFile("bootstrap/keygen.sh")
keyScript, err := ioutil.ReadFile("scripts/keygen.sh")
assert.Nil(t, err)

script, err := ioutil.ReadFile("bootstrap/token.sh")
script, err := ioutil.ReadFile("scripts/token.sh")
assert.Nil(t, err)
tokenScript := fmt.Sprintf(string(script), "test")

script, err = ioutil.ReadFile("bootstrap/daemon-up.sh")
script, err = ioutil.ReadFile("scripts/daemon-up.sh")
assert.Nil(t, err)
daemonScript := fmt.Sprintf(string(script), "test", "4303", "127.0.0.1")

Expand Down
6 changes: 3 additions & 3 deletions client/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (remote *RemoteVPS) GetIPAndPort() string {

// installDocker installs docker on a remote vps.
func (remote *RemoteVPS) installDocker(session SSHSession) error {
installDockerSh, err := internal.Asset("client/bootstrap/docker.sh")
installDockerSh, err := internal.Asset("client/scripts/docker.sh")
if err != nil {
return err
}
Expand All @@ -58,7 +58,7 @@ func (remote *RemoteVPS) installDocker(session SSHSession) error {
// keyGen creates a public-private key-pair on the remote vps
// and returns the public key.
func (remote *RemoteVPS) keyGen(session SSHSession) (*bytes.Buffer, error) {
scriptBytes, err := internal.Asset("client/bootstrap/keygen.sh")
scriptBytes, err := internal.Asset("client/scripts/keygen.sh")
if err != nil {
return nil, err
}
Expand All @@ -77,7 +77,7 @@ func (remote *RemoteVPS) keyGen(session SSHSession) (*bytes.Buffer, error) {
// getDaemonAPIToken returns the daemon API token for RESTful access
// to the daemon.
func (remote *RemoteVPS) getDaemonAPIToken(session SSHSession, daemonVersion string) (string, error) {
scriptBytes, err := internal.Asset("client/bootstrap/token.sh")
scriptBytes, err := internal.Asset("client/scripts/token.sh")
if err != nil {
return "", err
}
Expand Down

0 comments on commit b09272c

Please sign in to comment.