github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/pkg/cli/validate_test.go (about) 1 package cli 2 3 import ( 4 "bytes" 5 "testing" 6 7 "github.com/apprenda/kismatic/pkg/install" 8 ) 9 10 func TestValidateCmdPlanNotFound(t *testing.T) { 11 out := &bytes.Buffer{} 12 fp := &fakePlanner{ 13 exists: false, 14 } 15 opts := &validateOpts{ 16 planFile: "planFile", 17 verbose: false, 18 outputFormat: "table", 19 } 20 err := doValidate(out, fp, opts) 21 if err == nil { 22 t.Errorf("validate did not return an error when the plan does not exist") 23 } 24 25 if fp.readCalled { 26 t.Errorf("attempted to read a non-existent plan file") 27 } 28 } 29 30 func TestValidateCmdPlanInvalid(t *testing.T) { 31 out := &bytes.Buffer{} 32 fp := &fakePlanner{ 33 exists: true, 34 plan: &install.Plan{}, 35 } 36 opts := &validateOpts{ 37 planFile: "planFile", 38 verbose: false, 39 outputFormat: "table", 40 } 41 err := doValidate(out, fp, opts) 42 if err == nil { 43 t.Errorf("did not return an error with an invalid plan") 44 } 45 46 if !fp.readCalled { 47 t.Errorf("did not read the plan file") 48 } 49 }