Skip to content
Permalink
Browse files

fail when config contains invalid yaml

  • Loading branch information...
ezekg committed Apr 26, 2016
1 parent 196ff6d commit be71bf2fb25265f76d2e222df03def53bf3b695c
Showing with 27 additions and 2 deletions.
  1. +1 −1 hound.go
  2. +18 −0 hound_test.go
  3. +8 −1 main.go
@@ -33,7 +33,7 @@ func (h *Hound) New() bool {

err = h.parseConfig(config)
if err != nil {
return false
panic(err)
}

return true
@@ -201,6 +201,24 @@ index 000000..000000 000000
t.Logf("Did pass")
}
}

// Should fail when invalid Yaml is detected
{
badConfig := []byte(`
warn:
- 'string without a closing single quote
fail:
- 'some other string'
skip:
- '/bad.go
`)

if err := hound.parseConfig(badConfig); err != nil {
t.Logf("Did not parse")
} else {
t.Fatalf("Should not parse")
}
}
}

func getDiff(t *testing.T, diffContents string) (string, *diff.Hunk) {
@@ -13,14 +13,21 @@ import (
)

var (
version = "0.5.2"
version = "0.5.3"
showVersion = flag.Bool("v", false, "Show version")
noColor = flag.Bool("no-color", false, "Disable color output")
config = flag.String("config", ".githound.yml", "Hound config file")
bin = flag.String("bin", "git", "Executable binary to use for git command")
)

func main() {
defer func() {
if r := recover(); r != nil {
color.Red(fmt.Sprintf("error: %s\n", r))
os.Exit(1)
}
}()

flag.Parse()

if *showVersion {

0 comments on commit be71bf2

Please sign in to comment.
You can’t perform that action at this time.