Skip to content

Commit

Permalink
add go vet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdfischer committed Jun 20, 2018
1 parent 02cd083 commit 54c6a82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
16 changes: 7 additions & 9 deletions graphqlsch/graphqlsch.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,23 @@ type Field struct {
}

func (f Field) ToString() string {
var fmtStr string
var typeFmtStr string
var typeStr string
if f.IsArray {
if f.IsElemNullable {
typeFmtStr = "%v"
typeStr = fmt.Sprintf("%v", f.Type)
} else {
typeFmtStr = "%v!"
typeStr = fmt.Sprintf("%v!", f.Type)
}
for level := uint(0); level < f.ArrayDim; level++ {
typeFmtStr = fmt.Sprintf("[%v]", typeFmtStr)
typeStr = fmt.Sprintf("[%v]", typeStr)
}
} else {
typeFmtStr = "%v"
typeStr = fmt.Sprintf("%v", f.Type)
}
if !f.IsNullable {
typeFmtStr = fmt.Sprintf("%v!", typeFmtStr)
typeStr = fmt.Sprintf("%v!", typeStr)
}
fmtStr = fmt.Sprintf(" %%v: %v", typeFmtStr)
return fmt.Sprintf(fmtStr, f.Name, f.Type)
return fmt.Sprintf(" %v: %v", f.Name, typeStr)
}

type PrimitiveType string
Expand Down
9 changes: 9 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ if [ ! -z "$gofmt_output" ]; then
fi
printf "OK\n"

printf "Running go vet tests..."
go_vet_output="$(go vet -v ./... 2>&1 | grep ':' )"
# grep ':' is a hack-ish way to only match path/to/file.go:lineno:colno: vet msg
if [ ! -z "$go_vet_output" ]; then
printf "FAIL. output:\n$go_vet_output" 1>&2
exit 1
fi
printf "OK\n"

printf "Running 'go install'..."
go_install_output=`go install 2>&1`
if [ ! -z "$go_install_output" ]; then
Expand Down

0 comments on commit 54c6a82

Please sign in to comment.