woodpecker/yaml/branch_test.go

45 lines
1.1 KiB
Go
Raw Normal View History

2016-04-19 20:02:28 +00:00
package yaml
import (
"testing"
"github.com/franela/goblin"
)
func TestBranch(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("Branch filter", func() {
g.It("Should parse and match emtpy", func() {
branch := ParseBranchString("")
2016-05-10 05:57:57 +00:00
g.Assert(branch.Match("master")).IsTrue()
})
g.It("Should parse and match", func() {
branch := ParseBranchString("branches: { include: [ master, develop ] }")
2016-05-10 05:57:57 +00:00
g.Assert(branch.Match("master")).IsTrue()
})
g.It("Should parse and match shortand", func() {
branch := ParseBranchString("branches: [ master, develop ]")
2016-05-10 05:57:57 +00:00
g.Assert(branch.Match("master")).IsTrue()
})
g.It("Should parse and match shortand string", func() {
branch := ParseBranchString("branches: master")
2016-05-10 05:57:57 +00:00
g.Assert(branch.Match("master")).IsTrue()
})
g.It("Should parse and match exclude", func() {
branch := ParseBranchString("branches: { exclude: [ master, develop ] }")
2016-05-10 05:57:57 +00:00
g.Assert(branch.Match("master")).IsFalse()
})
g.It("Should parse and match exclude shorthand", func() {
branch := ParseBranchString("branches: { exclude: master }")
2016-05-10 05:57:57 +00:00
g.Assert(branch.Match("master")).IsFalse()
})
})
}