1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-30 08:06:52 +02:00
woodpecker/yaml/branch_test.go

45 lines
1.1 KiB
Go
Raw Normal View History

2016-04-19 22:02:28 +02: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 07:57:57 +02:00
g.Assert(branch.Match("master")).IsTrue()
})
g.It("Should parse and match", func() {
branch := ParseBranchString("branches: { include: [ master, develop ] }")
2016-05-10 07:57:57 +02:00
g.Assert(branch.Match("master")).IsTrue()
})
g.It("Should parse and match shortand", func() {
branch := ParseBranchString("branches: [ master, develop ]")
2016-05-10 07:57:57 +02:00
g.Assert(branch.Match("master")).IsTrue()
})
g.It("Should parse and match shortand string", func() {
branch := ParseBranchString("branches: master")
2016-05-10 07:57:57 +02:00
g.Assert(branch.Match("master")).IsTrue()
})
g.It("Should parse and match exclude", func() {
branch := ParseBranchString("branches: { exclude: [ master, develop ] }")
2016-05-10 07:57:57 +02:00
g.Assert(branch.Match("master")).IsFalse()
})
g.It("Should parse and match exclude shorthand", func() {
branch := ParseBranchString("branches: { exclude: master }")
2016-05-10 07:57:57 +02:00
g.Assert(branch.Match("master")).IsFalse()
})
})
}