-
Notifications
You must be signed in to change notification settings - Fork 85
/
step_transform_build_json_test.go
57 lines (41 loc) · 1.32 KB
/
step_transform_build_json_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package worker
import (
"testing"
gocontext "golang.org/x/net/context"
"github.com/bitly/go-simplejson"
"github.com/mitchellh/multistep"
"github.com/stretchr/testify/assert"
"github.com/travis-ci/worker/backend"
"github.com/travis-ci/worker/config"
)
func setupStepTransformBuildJSON(cfg *config.ProviderConfig) (*stepTransformBuildJSON, multistep.StateBag) {
s := &stepTransformBuildJSON{}
bp, _ := backend.NewBackendProvider("fake", cfg)
ctx := gocontext.TODO()
instance, _ := bp.Start(ctx, nil)
rawPayload, _ := simplejson.NewJson([]byte("{}"))
job := &fakeJob{
rawPayload: rawPayload,
}
state := &multistep.BasicStateBag{}
state.Put("ctx", ctx)
state.Put("buildJob", job)
state.Put("instance", instance)
return s, state
}
func TestStepTransformBuildJSON_Run(t *testing.T) {
cfg := config.ProviderConfigFromMap(map[string]string{
"PAYLOAD_FILTER_EXECUTABLE": "",
})
s, state := setupStepTransformBuildJSON(cfg)
action := s.Run(state)
assert.Equal(t, multistep.ActionContinue, action)
}
func TestStepTransformBuildJSON_RunWithExecutableConfigured(t *testing.T) {
cfg := config.ProviderConfigFromMap(map[string]string{
"PAYLOAD_FILTER_EXECUTABLE": "/usr/local/bin/filter.py",
})
s, state := setupStepTransformBuildJSON(cfg)
action := s.Run(state)
assert.Equal(t, multistep.ActionContinue, action)
}