test updates

Signed-off-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
Casey Lee
2020-02-11 23:55:20 -08:00
parent f7252cbcf9
commit 64562d41ab
11 changed files with 37 additions and 30 deletions

View File

@@ -4,7 +4,7 @@ import (
"strings"
"testing"
"gotest.tools/assert"
"github.com/stretchr/testify/assert"
)
func TestReadWorkflow_StringEvent(t *testing.T) {
@@ -20,9 +20,10 @@ jobs:
`
workflow, err := ReadWorkflow(strings.NewReader(yaml))
assert.NilError(t, err, "read workflow should succeed")
assert.NoError(t, err, "read workflow should succeed")
assert.DeepEqual(t, workflow.On(), []string{"push"})
assert.Len(t, workflow.On(), 1)
assert.Contains(t, workflow.On(), "push")
}
func TestReadWorkflow_ListEvent(t *testing.T) {
@@ -38,9 +39,11 @@ jobs:
`
workflow, err := ReadWorkflow(strings.NewReader(yaml))
assert.NilError(t, err, "read workflow should succeed")
assert.NoError(t, err, "read workflow should succeed")
assert.DeepEqual(t, workflow.On(), []string{"push", "pull_request"})
assert.Len(t, workflow.On(), 2)
assert.Contains(t, workflow.On(), "push")
assert.Contains(t, workflow.On(), "pull_request")
}
func TestReadWorkflow_MapEvent(t *testing.T) {
@@ -62,7 +65,8 @@ jobs:
`
workflow, err := ReadWorkflow(strings.NewReader(yaml))
assert.NilError(t, err, "read workflow should succeed")
assert.DeepEqual(t, workflow.On(), []string{"push", "pull_request"})
assert.NoError(t, err, "read workflow should succeed")
assert.Len(t, workflow.On(), 2)
assert.Contains(t, workflow.On(), "push")
assert.Contains(t, workflow.On(), "pull_request")
}

View File

@@ -33,10 +33,10 @@ func TestAddpath(t *testing.T) {
rc := new(RunContext)
handler := rc.commandHandler(ctx)
handler("::add-path::/zoo")
handler("::add-path::/zoo\n")
assert.Equal("/zoo:", rc.Env["PATH"])
handler("::add-path::/booo")
handler("::add-path::/booo\n")
assert.Equal("/booo:/zoo:", rc.Env["PATH"])
}

View File

@@ -128,7 +128,11 @@ func (rc *RunContext) runContainer(containerSpec *model.ContainerSpec) common.Ex
rawLogger := common.Logger(ctx).WithField("raw_output", true)
logWriter := common.NewLineWriter(rc.commandHandler(ctx), func(s string) {
rawLogger.Debugf(s)
if rc.Config.LogOutput {
rawLogger.Infof(s)
} else {
rawLogger.Debugf(s)
}
})
return container.NewDockerRunExecutor(container.NewDockerRunExecutorInput{

View File

@@ -22,6 +22,7 @@ type Config struct {
EventPath string // path to JSON file to use for event.json in containers
ReuseContainers bool // reuse containers to maintain state
ForcePull bool // force pulling of the image, if already present
LogOutput bool // log the output from docker run
}
type runnerImpl struct {

View File

@@ -37,18 +37,15 @@ func TestRunEvent(t *testing.T) {
eventName string
errorMessage string
}{
{"basic", "push", ""},
{"fail", "push", "exit with `FAILURE`: 1"},
{"runs-on", "push", ""},
/*
{"basic", "push", ""},
{"fail", "push", "exit with `FAILURE`: 1"},
{"runs-on", "push", ""},
{"job-container", "push", ""},
{"uses-docker-url", "push", ""},
{"remote-action-docker", "push", ""},
{"remote-action-js", "push", ""},
{"local-action-docker-url", "push", ""},
{"local-action-dockerfile", "push", ""},
*/
{"job-container", "push", ""},
{"uses-docker-url", "push", ""},
{"remote-action-docker", "push", ""},
{"remote-action-js", "push", ""},
{"local-action-docker-url", "push", ""},
{"local-action-dockerfile", "push", ""},
}
log.SetLevel(log.DebugLevel)