mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-06 08:16:19 +02:00
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
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("")
|
|
g.Assert(branch.Match("master")).IsTrue()
|
|
})
|
|
|
|
g.It("Should parse and match", func() {
|
|
branch := ParseBranchString("branches: { include: [ master, develop ] }")
|
|
g.Assert(branch.Match("master")).IsTrue()
|
|
})
|
|
|
|
g.It("Should parse and match shortand", func() {
|
|
branch := ParseBranchString("branches: [ master, develop ]")
|
|
g.Assert(branch.Match("master")).IsTrue()
|
|
})
|
|
|
|
g.It("Should parse and match shortand string", func() {
|
|
branch := ParseBranchString("branches: master")
|
|
g.Assert(branch.Match("master")).IsTrue()
|
|
})
|
|
|
|
g.It("Should parse and match exclude", func() {
|
|
branch := ParseBranchString("branches: { exclude: [ master, develop ] }")
|
|
g.Assert(branch.Match("master")).IsFalse()
|
|
})
|
|
|
|
g.It("Should parse and match exclude shorthand", func() {
|
|
branch := ParseBranchString("branches: { exclude: master }")
|
|
g.Assert(branch.Match("master")).IsFalse()
|
|
})
|
|
})
|
|
}
|