harness-drone/engine/compiler/builtin/args_test.go
2016-04-16 00:51:05 -07:00

46 lines
928 B
Go

package builtin
import (
"testing"
"github.com/drone/drone/engine/compiler/parse"
"github.com/drone/drone/engine/runner"
"github.com/franela/goblin"
)
func Test_args(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("plugins arguments", func() {
g.It("should ignore non-plugin containers", func() {
root := parse.NewRootNode()
c := root.NewShellNode()
c.Container = runner.Container{}
c.Vargs = map[string]interface{}{
"depth": 50,
}
ops := NewArgsOp()
ops.VisitContainer(c)
g.Assert(c.Container.Environment["PLUGIN_DEPTH"]).Equal("")
})
g.It("should include args as environment variable", func() {
root := parse.NewRootNode()
c := root.NewPluginNode()
c.Container = runner.Container{}
c.Vargs = map[string]interface{}{
"depth": 50,
}
ops := NewArgsOp()
ops.VisitContainer(c)
g.Assert(c.Container.Environment["PLUGIN_DEPTH"]).Equal("50")
})
})
}