Skip to content

Commit

Permalink
#58 Prepare test data before start working on the feature
Browse files Browse the repository at this point in the history
  • Loading branch information
zshamrock committed May 5, 2018
1 parent f503244 commit 58ee58a
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 0 deletions.
22 changes: 22 additions & 0 deletions command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ func TestGetCommand(t *testing.T) {
}
}

func TestGetCommandExtraArgs(t *testing.T) {
followFlags := []string{"", "-f", "--follow"}
for _, followFlag := range followFlags {
flags := flag.FlagSet{}
flags.Bool("follow", false, "")
commandText := "tail -f -n 10 logs/rest.log"
flags.Parse([]string{"--", followFlag, "dev", commandText})
app := cli.NewApp()
context := cli.NewContext(app, &flags, nil)
command, extraArgs := getCommand(context, true)
if !command.IsAdHoc() {
t.Errorf("Command name should be ad-hoc, but got %s", command.Name)
}
if command.Command != commandText {
t.Errorf("Command should be %s, but got %s", commandText, command.Command)
}
if extraArgs != "" {
t.Errorf("Extra args should be empty, but got %s", extraArgs)
}
}
}

func TestContainsFollow(t *testing.T) {
followFlags := []string{"-f", "--follow"}
for _, followFlag := range followFlags {
Expand Down
6 changes: 6 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
There are 2 env variables which control where the `vmx` looks for the application config and SSH config.

They are: `VMX_HOME` and `VMX_SSH_CONFIG_HOME`.

So the data in this directory is used for testing when the corresponding env variables set to point to `config` and
`ssh` inner directories correspondingly.
16 changes: 16 additions & 0 deletions test/config/commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[logs]
command=cat logs/app.log

[app-logs]
command=tail -f -n 10 logs/app.log

[follow-logs]
workingdir=/opt/app1
command=tail -f -n 10 logs/app1.log
follow=true

[redeploy!]
command=./redeploy.sh

[disk-space]
command=df -h
6 changes: 6 additions & 0 deletions test/config/defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[all]
workingdir=/opt/app

#
[app2-prod*]
workingdir=/opt/app2
38 changes: 38 additions & 0 deletions test/config/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# dev
[dev]
app-dev1
db-dev1

[dev-db]
db-dev1

# prod
[prod]
app1-prod1
app1-prod2
db-prod1
db-prod2

[prod-db]
db-prod1
db-prod2

[prod-app1]
app1-prod1
app1-prod2

[prod-app2]
app2-prod1
app2-prod2

[all-db:children]
dev-db
prod-db

[prod-app:children]
prod-app1
prod-app2

[all-prod:children]
prod-app
prod-db
24 changes: 24 additions & 0 deletions test/ssh/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Host app-dev1
User vmx
Hostname 192.168.1.1
Host db-dev1
User vmx
Hostname 192.168.1.2
Host app1-prod1
User vmx
Hostname 192.168.1.3
Host app1-prod2
User vmx
Hostname 192.168.1.4
Host db-prod1
User vmx
Hostname 192.168.1.5
Host db-prod2
User vmx
Hostname 192.168.1.6
Host app2-prod1
User vmx
Hostname 192.168.1.7
Host app2-prod2
User vmx
Hostname 192.168.1.8

0 comments on commit 58ee58a

Please sign in to comment.