-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added circleci config and some tests.
- Loading branch information
Sami Alajrami
committed
Nov 15, 2017
1 parent
f2948bf
commit 56245d8
Showing
6 changed files
with
363 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Golang CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-go/ for more details | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
# specify the version | ||
- image: circleci/golang:1.8 | ||
|
||
# Specify service dependencies here if necessary | ||
# CircleCI maintains a library of pre-built images | ||
# documented at https://circleci.com/docs/2.0/circleci-images/ | ||
# - image: circleci/postgres:9.4 | ||
|
||
#### TEMPLATE_NOTE: go expects specific checkout path representing url | ||
#### expecting it in the form of | ||
#### /go/src/github.com/circleci/go-tool | ||
#### /go/src/bitbucket.org/circleci/go-tool | ||
working_directory: /go/src/github.com/praqma/helmsman | ||
steps: | ||
- checkout | ||
|
||
# specify any bash command here prefixed with `run: ` | ||
- run: go get github.com/BurntSushi/toml | ||
- run: go get github.com/goreleaser/goreleaser | ||
- run: go test |
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,110 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
// func Test_command_printDescription(t *testing.T) { | ||
// type fields struct { | ||
// Cmd string | ||
// Args []string | ||
// Description string | ||
// } | ||
// tests := []struct { | ||
// name string | ||
// fields fields | ||
// }{ | ||
// // TODO: Add test cases. | ||
// } | ||
// for _, tt := range tests { | ||
// t.Run(tt.name, func(t *testing.T) { | ||
// c := command{ | ||
// Cmd: tt.fields.Cmd, | ||
// Args: tt.fields.Args, | ||
// Description: tt.fields.Description, | ||
// } | ||
// c.printDescription() | ||
// }) | ||
// } | ||
// } | ||
|
||
// func Test_command_printFullCommand(t *testing.T) { | ||
// type fields struct { | ||
// Cmd string | ||
// Args []string | ||
// Description string | ||
// } | ||
// tests := []struct { | ||
// name string | ||
// fields fields | ||
// }{ | ||
// // TODO: Add test cases. | ||
// } | ||
// for _, tt := range tests { | ||
// t.Run(tt.name, func(t *testing.T) { | ||
// c := command{ | ||
// Cmd: tt.fields.Cmd, | ||
// Args: tt.fields.Args, | ||
// Description: tt.fields.Description, | ||
// } | ||
// c.printFullCommand() | ||
// }) | ||
// } | ||
// } | ||
|
||
func Test_command_exec(t *testing.T) { | ||
type fields struct { | ||
Cmd string | ||
Args []string | ||
Description string | ||
} | ||
type args struct { | ||
debug bool | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
want int | ||
want1 string | ||
}{ | ||
{ | ||
name: "echo", | ||
fields: fields{ | ||
Cmd: "bash", | ||
Args: []string{"-c", "echo this is fun"}, | ||
Description: "A bash command execution test with echo.", | ||
}, | ||
args: args{debug: false}, | ||
want: 0, | ||
want1: "this is fun", | ||
}, { | ||
name: "exitCode", | ||
fields: fields{ | ||
Cmd: "bash", | ||
Args: []string{"-c", "echo $?"}, | ||
Description: "A bash command execution test with exitCode.", | ||
}, | ||
args: args{debug: false}, | ||
want: 0, | ||
want1: "0", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
c := command{ | ||
Cmd: tt.fields.Cmd, | ||
Args: tt.fields.Args, | ||
Description: tt.fields.Description, | ||
} | ||
got, got1 := c.exec(tt.args.debug) | ||
if got != tt.want { | ||
t.Errorf("command.exec() got = %v, want %v", got, tt.want) | ||
} | ||
if strings.TrimSpace(got1) != tt.want1 { | ||
t.Errorf("command.exec() got1 = %v, want %v", got1, tt.want1) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.