-
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.
- Loading branch information
1 parent
e8e0d95
commit e4aa7a8
Showing
4 changed files
with
61 additions
and
3 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
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,11 @@ | ||
shell: /bin/bash | ||
commands: | ||
foo: | ||
run: ls foo | ||
bar: | ||
needs: | ||
- foo | ||
run: ls bar | ||
baz: | ||
if: test -e foo.txt | ||
run: ls baz |
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,47 @@ | ||
package runny | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
type Input struct { | ||
command string | ||
maxLength int | ||
} | ||
|
||
type Param struct { | ||
input Input | ||
expected string | ||
} | ||
|
||
func TestCommandStringToSingleLine(t *testing.T) { | ||
params := []Param{ | ||
{input: Input{command: "", maxLength: 80}, expected: ""}, | ||
{input: Input{command: "foo bar wibble", maxLength: 10}, expected: "foo bar..."}, | ||
{input: Input{command: "foo\nbar", maxLength: 80}, expected: "foo; bar"}, | ||
{input: Input{command: " foo \n bar ", maxLength: 80}, expected: "foo; bar"}, | ||
} | ||
for _, p := range params { | ||
output := commandStringToSingleLine(p.input.command, p.input.maxLength) | ||
if output != p.expected { | ||
t.Fatalf("Expected %s, got %s\n", p.expected, output) | ||
} | ||
} | ||
} | ||
|
||
func TestReadConfig(t *testing.T) { | ||
conf, err := readConfig("fixtures/simple-good.yaml") | ||
if err != nil { | ||
t.Fatalf("Got error when reading in config file: %v\n", err) | ||
} | ||
|
||
expectedLenCommands := 3 | ||
if len(conf.Commands) != expectedLenCommands { | ||
t.Fatalf("Expected %d commands, got %d\n", expectedLenCommands, len(conf.Commands)) | ||
} | ||
|
||
expectedCommandFooRun := "ls foo" | ||
if conf.Commands["foo"].Run != expectedCommandFooRun { | ||
t.Fatalf("Expected foo command's run value to be %s, got %s", expectedCommandFooRun, conf.Commands["foo"].Run) | ||
} | ||
} |