mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-25 09:50:31 +00:00
40 lines
780 B
Go
40 lines
780 B
Go
package runner
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/franela/goblin"
|
|
)
|
|
|
|
func TestContainer(t *testing.T) {
|
|
g := goblin.Goblin(t)
|
|
|
|
g.Describe("Container validation", func() {
|
|
|
|
g.It("fails with an invalid name", func() {
|
|
c := Container{
|
|
Image: "golang:1.5",
|
|
}
|
|
err := c.Validate()
|
|
g.Assert(err != nil).IsTrue()
|
|
g.Assert(err.Error()).Equal("Missing container name")
|
|
})
|
|
|
|
g.It("fails with an invalid image", func() {
|
|
c := Container{
|
|
Name: "container_0",
|
|
}
|
|
err := c.Validate()
|
|
g.Assert(err != nil).IsTrue()
|
|
g.Assert(err.Error()).Equal("Missing container image")
|
|
})
|
|
|
|
g.It("passes with valid attributes", func() {
|
|
c := Container{
|
|
Name: "container_0",
|
|
Image: "golang:1.5",
|
|
}
|
|
g.Assert(c.Validate() == nil).IsTrue()
|
|
})
|
|
})
|
|
}
|