Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
adding tests for postgres
Browse files Browse the repository at this point in the history
Signed-off-by: Jason McCallister <jason@craftcms.com>
  • Loading branch information
jasonmccallister committed Apr 8, 2020
1 parent 9d432f5 commit ac0bab8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/action/destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ func TestDestroy(t *testing.T) {
Args: []string{"delete", "notpermanent"},
},
},
{
name: "can destroy a machine permanently",
args: args{
name: "ispermanent",
force: true,
},
want: &Action{
Type: "delete",
UseSyscall: false,
Args: []string{"delete", "ispermanent", "-p"},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
37 changes: 37 additions & 0 deletions internal/action/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ func TestCreateDatabaseContainer(t *testing.T) {
},
wantErr: false,
},
{
name: "create postgres 11.7",
args: args{
name: "postgresmachine",
engine: "postgres",
version: "11.7",
port: "5432",
},
want: &Action{
Type: "exec",
UseSyscall: false,
Args: []string{"exec", "postgresmachine", "--", "docker", "run", "-v", "postgres_11.7_5432:/var/lib/postgresql/data", "--name", "postgres_11.7_5432", "-d", "--restart=always", "-p", "5432:5432", "-e", "POSTGRES_PASSWORD=nitro", "-e", "POSTGRES_USER=nitro", "-e", "POSTGRES_DB=nitro", "postgres:11.7"},
},
wantErr: false,
},
{
name: "validation fails",
args: args{
name: "postgresmachine",
engine: "postgres",
version: "110",
port: "5432",
},
want: nil,
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -76,6 +102,17 @@ func TestCreateDatabaseVolume(t *testing.T) {
},
wantErr: false,
},
{
name: "validation fails",
args: args{
name: "postgresmachine",
engine: "postgres",
version: "110",
port: "5432",
},
want: nil,
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit ac0bab8

Please # to comment.