mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-18 14:36:30 +00:00
32 lines
639 B
Go
32 lines
639 B
Go
package script
|
|
|
|
import (
|
|
"github.com/franela/goblin"
|
|
"testing"
|
|
)
|
|
|
|
func Test_Inject(t *testing.T) {
|
|
|
|
g := goblin.Goblin(t)
|
|
g.Describe("Inject params", func() {
|
|
|
|
g.It("Should replace vars with $$", func() {
|
|
s := "echo $$FOO $BAR"
|
|
m := map[string]string{}
|
|
m["FOO"] = "BAZ"
|
|
g.Assert("echo BAZ $BAR").Equal(Inject(s, m))
|
|
})
|
|
|
|
g.It("Should not replace vars with single $", func() {
|
|
s := "echo $FOO $BAR"
|
|
m := map[string]string{}
|
|
m["FOO"] = "BAZ"
|
|
g.Assert(s).Equal(Inject(s, m))
|
|
})
|
|
|
|
g.It("Should not replace vars in nil map", func() {
|
|
s := "echo $$FOO $BAR"
|
|
g.Assert(s).Equal(Inject(s, nil))
|
|
})
|
|
})
|
|
}
|