-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from chroju/v0.3.1
v0.3.1
- Loading branch information
Showing
21 changed files
with
907 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
name: test | ||
on: pull_request | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
test: | ||
name: Test Parade | ||
runs-on: ubuntu-18.04 | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
- name: Setup go | ||
uses: actions/setup-go@v1 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.15.6" | ||
go-version: "1.16.0" | ||
- name: Test all | ||
env: | ||
GO111MODULE: on | ||
run: | | ||
export PATH=$PATH:$(go env GOPATH)/bin | ||
go get golang.org/x/lint/golint | ||
make test | ||
make test-coverage | ||
- name: Install goveralls | ||
env: | ||
GO111MODULE: off | ||
run: go get github.com/mattn/goveralls | ||
- name: Send coverage | ||
uses: shogo82148/actions-goveralls@v1 | ||
with: | ||
path-to-profile: covprofile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
**/parade | ||
**/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/chroju/parade/ssmctl" | ||
) | ||
|
||
const ( | ||
usageDelHelp = " -h, --help help for del\n\n" | ||
) | ||
|
||
func Test_delCommand(t *testing.T) { | ||
voidCmd := newDelCommand( | ||
&GlobalOption{ | ||
Out: &bytes.Buffer{}, | ||
ErrOut: &bytes.Buffer{}, | ||
}, | ||
) | ||
tests := []struct { | ||
name string | ||
command string | ||
wantOutWriter string | ||
wantErrWriter string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "one arg", | ||
command: "/service1/dev/key1", | ||
wantOutWriter: "", | ||
wantErrWriter: "Delete `/service1/dev/key1` (value: dev_value1) ? (Y/n)\n", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "one arg with force option", | ||
command: "/service1/dev/key1 --force", | ||
wantOutWriter: "", | ||
wantErrWriter: "", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "two args", | ||
command: "dev prod", | ||
wantOutWriter: fmt.Sprintf("Error: accepts 1 arg(s), received 2\n%s%s", voidCmd.UsageString(), usageDelHelp), | ||
wantErrWriter: "", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "no args", | ||
command: "", | ||
wantOutWriter: fmt.Sprintf("Error: accepts 1 arg(s), received 0\n%s%s", voidCmd.UsageString(), usageDelHelp), | ||
wantErrWriter: "", | ||
wantErr: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
ssmManager := ssmctl.NewMockSSMManager() | ||
outWriter := &bytes.Buffer{} | ||
errWriter := &bytes.Buffer{} | ||
|
||
o := &GlobalOption{ | ||
SSMManager: ssmManager, | ||
Out: outWriter, | ||
ErrOut: errWriter, | ||
} | ||
|
||
cmd := newDelCommand(o) | ||
if tt.command != "" { | ||
cmd.SetArgs(strings.Split(tt.command, " ")) | ||
} | ||
|
||
if err := cmd.Execute(); (err != nil) != tt.wantErr { | ||
t.Errorf("get() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if gotOutWriter := outWriter.String(); gotOutWriter != tt.wantOutWriter { | ||
t.Errorf("get() = %v, want %v", gotOutWriter, tt.wantOutWriter) | ||
} | ||
if gotErrWriter := errWriter.String(); gotErrWriter != tt.wantErrWriter { | ||
t.Errorf("get() = %v, want %v", gotErrWriter, tt.wantErrWriter) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.