Skip to content

Commit

Permalink
test: Added a test for scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
yottahmd committed Jul 25, 2022
1 parent f018b16 commit 51a2b91
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,25 @@ func TestNodeTeardownFailure(t *testing.T) {
require.Error(t, nodes[0].Error)
}

func TestTakeOutputFromPrevStep(t *testing.T) {
s1 := step("1", "echo take-output")
s1.Output = "PREV_OUT"

s2 := step("2", "sh", "1")
s2.Script = "echo $PREV_OUT"
s2.Output = "TOOK_PREV_OUT"

g, sc := newTestSchedule(t, &Config{}, s1, s2)
err := sc.Schedule(g, nil)
require.NoError(t, err)

nodes := g.Nodes()
require.Equal(t, NodeStatus_Success, nodes[0].ReadStatus())
require.Equal(t, NodeStatus_Success, nodes[1].ReadStatus())

require.Equal(t, "take-output", os.ExpandEnv("$TOOK_PREV_OUT"))
}

func step(name, command string, depends ...string) *config.Step {
cmd, args := utils.SplitCommand(command)
return &config.Step{
Expand Down

0 comments on commit 51a2b91

Please sign in to comment.