check for commands in setup sections in linter

This commit is contained in:
Brad Rydzewski 2015-08-19 12:26:16 -07:00
parent df1aa0cd0b
commit 1947657e25
2 changed files with 6 additions and 5 deletions

View file

@ -50,8 +50,8 @@ func expectImage(c *common.Config) error {
// lint rule that fails when no build commands are defined
func expectCommand(c *common.Config) error {
if c.Build.Config == nil || c.Build.Config["commands"] == nil {
return fmt.Errorf("Yaml must define build commands")
if c.Setup.Config == nil || c.Setup.Config["commands"] == nil {
return fmt.Errorf("Yaml must define build / setup commands")
}
return nil
}

View file

@ -26,7 +26,7 @@ func Test_Linter(t *testing.T) {
g.It("Should fail when no commands", func() {
c := &common.Config{
Build: &common.Step{},
Setup: &common.Step{},
}
g.Assert(expectCommand(c) != nil).IsTrue()
})
@ -46,8 +46,9 @@ func Test_Linter(t *testing.T) {
c := &common.Config{}
c.Build = &common.Step{}
c.Build.Image = "golang"
c.Build.Config = map[string]interface{}{}
c.Build.Config["commands"] = []string{"go build", "go test"}
c.Setup = &common.Step{}
c.Setup.Config = map[string]interface{}{}
c.Setup.Config["commands"] = []string{"go build", "go test"}
c.Clone = &common.Step{}
c.Clone.Config = map[string]interface{}{}
c.Clone.Config["path"] = "/drone/src/foo/bar"