Repository: honeydipper/honeydipper (go)

Issue:
configcheck for contexts exiting 0 on errors
```
730f75d634de:~/project# /opt/honeydipper/drivers/builtin/honeydipper configcheck

Found error in Contexts
─────────────────────────────────────────────────────────────
context(_default): workflow `spanner_asdf` not defined
context(_default): workflow `spanner_restore` not defined
730f75d634de:~/project# echo $?
0
```

Pull request:
fix(configcheck): exit non-zero on context errors
#### Description
Context errors weren't causing configcheck to exit with a non-0 exit code

* Return 1 on context error
* Add test coverage for runConfigCheck() return code

#### This PR fixes the following issues
Fixes #255


Patch:
diff --git a/cmd/honeydipper/configcheck.go b/cmd/honeydipper/configcheck.go
index 1eb2546..de630fd 100644
--- a/cmd/honeydipper/configcheck.go
+++ b/cmd/honeydipper/configcheck.go
@@ -70,6 +70,7 @@ func runConfigCheck(cfg *config.Config) int {
 						contextErrors = true
 					}
 					fmt.Printf("context(%s): %s\n", contextName, aurora.Red(errMsg))
+					ret = 1
 				}
 			}
 		}


Test patch:
diff --git a/cmd/honeydipper/configcheck_test.go b/cmd/honeydipper/configcheck_test.go
index 77ca922..2d1cb41 100644
--- a/cmd/honeydipper/configcheck_test.go
+++ b/cmd/honeydipper/configcheck_test.go
@@ -9,10 +9,71 @@
 package main
 
 import (
+	"fmt"
 	"github.com/honeydipper/honeydipper/internal/config"
+	"github.com/stretchr/testify/assert"
 	"testing"
 )
 
+func TestRunConfigCheck(t *testing.T) {
+	runConfigTestCases := []interface{}{
+		[]interface{}{
+			&config.Config{
+				DataSet: &config.DataSet{},
+			},
+			0,
+			"runConfigCheck should return zero for empty config repo",
+		},
+		[]interface{}{
+			&config.Config{
+				DataSet: &config.DataSet{},
+				Loaded: map[config.RepoInfo]*config.Repo{
+					config.RepoInfo{Repo: "good one"}: &config.Repo{Errors: nil},
+					config.RepoInfo{Repo: "bad one"}:  &config.Repo{Errors: []config.Error{config.Error{Error: fmt.Errorf("error converting YAML to JSON: yaml: %s", "test.yaml"), File: "test"}}},
+				},
+			},
+			1,
+			"runConfigCheck should return non-zero if there is error loading yaml",
+		},
+		[]interface{}{
+			&config.Config{
+				DataSet: &config.DataSet{
+					Contexts: map[string]interface{}{"_default": map[string]interface{}{"wf-not-exists": map[string]interface{}{"data": "value"}}},
+				},
+			},
+			1,
+			"runConfigCheck should return non-zero if a context is missing matching workflow",
+		},
+		[]interface{}{
+			&config.Config{
+				DataSet: &config.DataSet{
+					Rules: []config.Rule{
+						{When: config.Trigger{Driver: "non-exist"}, Do: config.Workflow{Workflow: "non-exist"}},
+					},
+				},
+			},
+			1,
+			"runConfigCheck should return non-zero if a rule calls a missing workflow",
+		},
+		[]interface{}{
+			&config.Config{
+				DataSet: &config.DataSet{
+					Workflows: map[string]config.Workflow{"test-workflow": config.Workflow{Workflow: "dne"}},
+				},
+			},
+			1,
+			"runConfigCheck should return non-zero if a workflow calls a missing workflow",
+		},
+	}
+
+	for _, tcase := range runConfigTestCases {
+		tc := tcase.([]interface{})
+		result := runConfigCheck(tc[0].(*config.Config))
+		assert.Equal(t, tc[1], result, tc[2])
+	}
+
+}
+
 func TestCheckObjectExistsWorkFlowDoesNotExist(t *testing.T) {
 	defer recoverAssertion(`workflow "test-fail" not defined`, t)
 	workflows := map[string]config.Workflow{