Ejemplo n.º 1
0
func TestConfig(t *testing.T) {
	Convey("Loading the spanner config", t, func() {
		fixture, err := os.Open("fixture.toml")
		if err != nil {
			panic(err)
		}
		config, err := c.Read(fixture)
		if err != nil {
			panic(err)
		}

		Convey("Reading Spanner Name Metadata", func() {
			So(config.Spanner.Name, ShouldEqual, "ruby")
		})

		Convey("Reading Spanner Version Metadata", func() {
			So(config.Spanner.Version, ShouldEqual, "2.2.3")
		})

		Convey("Reading Step Config", func() {
			So(config.Step[0].Dir, ShouldEqual, "vendor/bundle")
			So(config.Step[0].Script[0], ShouldResemble, []string{"bundle", "install", "-r3", "-j4", "--path", "vendor/bundle"})
			So(config.Step[0].Script[1], ShouldResemble, []string{"bundle", "clean"})
		})
	})

	Convey("Errors", t, func() {
		u := unreadable{}
		_, err := c.Read(u)
		So(err.Error(), ShouldEqual, "could not read, because broken")

		Convey("invalid config", func() {
			invalid, _ := os.Open("fixture.broken")
			_, err := c.Read(invalid)
			So(err.Error(), ShouldStartWith, "toml: unmarshal:")
		})
	})

}
Ejemplo n.º 2
0
func main() {
	defer handleFatal()

	confFile, err := os.Open("/etc/assemblyline/spanner/" + os.Args[1] + ".toml")
	check(err)
	config, err := config.Read(confFile)
	check(err)

	assemblyFile, err := os.Open("Assemblyfile")
	check(err)
	af, err := assemblyfile.Read(assemblyFile)
	check(err)

	c := cache.New(af.Hash(), fileStore)

	l.Title("Building", af.Application.Name, "with", config.Spanner.Name, config.Spanner.Version, config.Spanner.Task)
	for _, step := range config.Step {
		step.Cache = c
		err := step.Exec()
		check(err)
	}
}