grim/local-pipelines

Closing the golang branch since rewriting in golang doesn't gain us much now that we're on pypi
package main
import (
"testing"
. "gopkg.in/check.v1"
)
func TestPlan(t *testing.T) { TestingT(t) }
type PlanSuite struct{}
var _ = Suite(&PlanSuite{})
func (s *PlanSuite) testPlan(c *C, inp string, exp *Plan) {
act, err := load([]byte(inp))
c.Assert(err, IsNil)
c.Assert(act, DeepEquals, exp)
}
func (s *PlanSuite) TestPlanSimple(c *C) {
inp := `pipelines:
default:
- step:
script:
- echo "hello"`
exp := &Plan{
Image: "",
Pipelines: Pipelines{
Default: []Step{
Step{
Script: []string{"echo \"hello\""},
},
},
},
}
s.testPlan(c, inp, exp)
}
func (s *PlanSuite) TestPlanComplex(c *C) {
inp := `image: debian:jessie
pipelines:
default:
- step:
image: pidgin/libpurple-2-x-y-dev:debian-stretch
script:
- apt-get update
- apt-get install -y libjson-glib-dev libprotobuf-c-dev protobuf-c-compiler
- make clean
- make -j $(grep processor /proc/cpuinfo | wc -l)
- step:
image: pidgin/libpurple-2-x-y-dev:debian-jessie
script:
- apt-get update
- apt-get install -y libjson-glib-dev libprotobuf-c-dev protobuf-c-compiler
- make clean
- make -j $(grep processor /proc/cpuinfo | wc -l)`
exp := &Plan{
Image: "debian:jessie",
Pipelines: Pipelines{
Default: []Step{
Step{
Image: "pidgin/libpurple-2-x-y-dev:debian-stretch",
Script: []string{
"apt-get update",
"apt-get install -y libjson-glib-dev libprotobuf-c-dev protobuf-c-compiler",
"make clean",
"make -j $(grep processor /proc/cpuinfo | wc -l)",
},
},
Step{
Image: "pidgin/libpurple-2-x-y-dev:debian-jessie",
Script: []string{
"apt-get update",
"apt-get install -y libjson-glib-dev libprotobuf-c-dev protobuf-c-compiler",
"make clean",
"make -j $(grep processor /proc/cpuinfo | wc -l)",
},
},
},
},
}
s.testPlan(c, inp, exp)
}