Skip to content

Commit

Permalink
fix(test-style): make fmt fail style-test and fix existing formatting…
Browse files Browse the repository at this point in the history
… errors (#135)
  • Loading branch information
Joshua-Anderson committed Jul 27, 2016
1 parent 89e4177 commit c655ea0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ GCS_BUCKET ?= "gs://workflow-cli"

GO_FILES = $(wildcard *.go)
GO_LDFLAGS = -ldflags "-s -X ${repo_path}/version.BuildVersion=${VERSION}"
GO_PACKAGES = cmd parser $(wildcard pkg/*)
GO_PACKAGES = cmd parser cli $(wildcard pkg/*)
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
GOFMT = gofmt -e -l -s
GOFMT = gofmtresult=$$(gofmt -e -l -s ${GO_FILES} ${GO_PACKAGES}); if [[ -n $$gofmtresult ]]; then echo "gofmt errors found in the following files: $${gofmtresult}"; false; fi;
GOTEST = go test --cover --race -v

# The tag of the commit
Expand Down Expand Up @@ -96,7 +96,8 @@ setup-gotools:
test: test-style test-unit

test-style:
${DEV_ENV_CMD} sh -c '${GOFMT} ${GO_FILES} ${GO_PACKAGES} && go vet $(repo_path) $(GO_PACKAGES_REPO_PATH)'
${DEV_ENV_CMD} bash -c '${GOFMT}'
${DEV_ENV_CMD} sh -c 'go vet $(repo_path) $(GO_PACKAGES_REPO_PATH)'
@for i in $(addsuffix /...,$(GO_PACKAGES)); do \
${DEV_ENV_CMD} golint $$i; \
done
Expand Down
1 change: 1 addition & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cli

// Shortcuts is a map of all the shortcuts supported by the CLI
var Shortcuts = map[string]string{
"create": "apps:create",
"destroy": "apps:destroy",
Expand Down
4 changes: 2 additions & 2 deletions cmd/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ type expandURLCases struct {

func TestExpandUrl(t *testing.T) {
checks := []expandURLCases{
expandURLCases{
{
Input: "test.com",
Expected: "test.com",
},
expandURLCases{
{
Input: "test",
Expected: "test.foo.com",
},
Expand Down
8 changes: 4 additions & 4 deletions cmd/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@ type chooseKeyCases struct {

func TestChooseKey(t *testing.T) {
testKeys := []api.KeyCreateRequest{
api.KeyCreateRequest{},
{},
}

checks := []chooseKeyCases{
chooseKeyCases{
{
Reader: strings.NewReader("-1"),
Expected: "-1 is not a valid option",
},
chooseKeyCases{
{
Reader: strings.NewReader("2"),
Expected: "2 is not a valid option",
},
chooseKeyCases{
{
Reader: strings.NewReader("a"),
Expected: "a is not a valid integer",
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func parseType(target string, appID string) (string, string) {
psType, psName := "", ""

if strings.Contains(target, "-") {
replaced := strings.Replace(target, appID + "-", "", 1)
replaced := strings.Replace(target, appID+"-", "", 1)
parts := strings.Split(replaced, "-")
// the API requires the type, for now
// regex matches against how Deployment pod name is constructed
Expand Down
13 changes: 6 additions & 7 deletions cmd/shortcuts_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package cmd

import (
"testing"
"testing"
)


func TestShortcutsList(t *testing.T) {
t.Parallel()

expected := `create -> apps:create
expected := `create -> apps:create
destroy -> apps:destroy
info -> apps:info
login -> auth:login
Expand All @@ -27,9 +26,9 @@ sharing:list -> perms:list
sharing:remove -> perms:delete
whoami -> auth:whoami
`
actual := sortShortcuts()
if actual != expected {
t.Errorf("Expected %s, Got %s", expected, actual)
}
actual := sortShortcuts()
if actual != expected {
t.Errorf("Expected %s, Got %s", expected, actual)
}

}

0 comments on commit c655ea0

Please sign in to comment.