mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-25 01:40:30 +00:00
33 lines
684 B
Go
33 lines
684 B
Go
|
package yaml
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/franela/goblin"
|
||
|
)
|
||
|
|
||
|
func TestLabel(t *testing.T) {
|
||
|
|
||
|
g := goblin.Goblin(t)
|
||
|
g.Describe("Label parser", func() {
|
||
|
|
||
|
g.It("Should parse empty yaml", func() {
|
||
|
labels := ParseLabelString("")
|
||
|
g.Assert(len(labels)).Equal(0)
|
||
|
})
|
||
|
|
||
|
g.It("Should parse slice", func() {
|
||
|
labels := ParseLabelString("labels: [foo=bar, baz=boo]")
|
||
|
g.Assert(len(labels)).Equal(2)
|
||
|
g.Assert(labels["foo"]).Equal("bar")
|
||
|
g.Assert(labels["baz"]).Equal("boo")
|
||
|
})
|
||
|
|
||
|
g.It("Should parse map", func() {
|
||
|
labels := ParseLabelString("labels: {foo: bar, baz: boo}")
|
||
|
g.Assert(labels["foo"]).Equal("bar")
|
||
|
g.Assert(labels["baz"]).Equal("boo")
|
||
|
})
|
||
|
})
|
||
|
}
|