mirror of https://github.com/knative/pkg.git
golang format tools (#892)
Produced via: `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))` `goimports -w $(find -name '*.go' | grep -v vendor)` /assign n3wscott
This commit is contained in:
parent
0400231005
commit
cd063fbc21
|
|
@ -29,8 +29,8 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
invalidInputErrorPrefix = "invalid input: "
|
invalidInputErrorPrefix = "invalid input: "
|
||||||
defaultErrCode = 1
|
defaultErrCode = 1
|
||||||
separator = "\n"
|
separator = "\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunCommand will run the command and return the standard output, plus error if there is one.
|
// RunCommand will run the command and return the standard output, plus error if there is one.
|
||||||
|
|
@ -38,9 +38,9 @@ func RunCommand(cmdLine string) (string, error) {
|
||||||
cmdSplit, err := shell.Split(cmdLine)
|
cmdSplit, err := shell.Split(cmdLine)
|
||||||
if len(cmdSplit) == 0 || err != nil {
|
if len(cmdSplit) == 0 || err != nil {
|
||||||
return "", &CommandLineError{
|
return "", &CommandLineError{
|
||||||
Command: cmdLine,
|
Command: cmdLine,
|
||||||
ErrorOutput: []byte(invalidInputErrorPrefix + cmdLine),
|
ErrorOutput: []byte(invalidInputErrorPrefix + cmdLine),
|
||||||
ErrorCode: defaultErrCode,
|
ErrorCode: defaultErrCode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,9 +53,9 @@ func RunCommand(cmdLine string) (string, error) {
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return string(out), &CommandLineError{
|
return string(out), &CommandLineError{
|
||||||
Command: cmdLine,
|
Command: cmdLine,
|
||||||
ErrorOutput: eb.Bytes(),
|
ErrorOutput: eb.Bytes(),
|
||||||
ErrorCode: getErrorCode(err),
|
ErrorCode: getErrorCode(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ import (
|
||||||
|
|
||||||
func TestRunCommand(t *testing.T) {
|
func TestRunCommand(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
command string
|
command string
|
||||||
expectedOutput string
|
expectedOutput string
|
||||||
expectedErrorOutput string
|
expectedErrorOutput string
|
||||||
expectedErrorCode int
|
expectedErrorCode int
|
||||||
}{
|
}{
|
||||||
{"", "", invalidInputErrorPrefix + "", 1},
|
{"", "", invalidInputErrorPrefix + "", 1},
|
||||||
{" ", "", invalidInputErrorPrefix + " ", 1},
|
{" ", "", invalidInputErrorPrefix + " ", 1},
|
||||||
|
|
@ -62,10 +62,10 @@ func TestRunCommand(t *testing.T) {
|
||||||
|
|
||||||
func TestRunCommands(t *testing.T) {
|
func TestRunCommands(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
commands []string
|
commands []string
|
||||||
expectedOutput string
|
expectedOutput string
|
||||||
expectedErrorOutput string
|
expectedErrorOutput string
|
||||||
expectedErrorCode int
|
expectedErrorCode int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
[]string{"echo 123", "echo 234", "echo 345"},
|
[]string{"echo 123", "echo 234", "echo 345"},
|
||||||
|
|
@ -127,8 +127,8 @@ func TestRunCommands(t *testing.T) {
|
||||||
|
|
||||||
func TestRunCommandsInParallel(t *testing.T) {
|
func TestRunCommandsInParallel(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
commands []string
|
commands []string
|
||||||
possibleOutput []string
|
possibleOutput []string
|
||||||
possibleErrorOutput []string
|
possibleErrorOutput []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
@ -151,7 +151,7 @@ func TestRunCommandsInParallel(t *testing.T) {
|
||||||
out, err := RunCommandsInParallel(c.commands...)
|
out, err := RunCommandsInParallel(c.commands...)
|
||||||
|
|
||||||
idx := -1
|
idx := -1
|
||||||
for i := range c.possibleOutput {
|
for i := range c.possibleOutput {
|
||||||
if c.possibleOutput[i] == out {
|
if c.possibleOutput[i] == out {
|
||||||
idx = i
|
idx = i
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue