github.com/jchengjr77/canaveral@v1.0.1-0.20200715160102-ea9245d1a2fb/vscodesupport/openCode_test.go (about) 1 package vscodesupport 2 3 import ( 4 "errors" 5 "os/user" 6 "testing" 7 8 "github.com/jchengjr77/canaveral/lib" 9 ) 10 11 func TestOpenCode(t *testing.T) { 12 origOut := lib.RedirOut() 13 defer func() { 14 lib.ResetOut(origOut) 15 }() 16 // Set home directory path of current user 17 tempusr, err := user.Current() 18 lib.Check(err) 19 tempHome := tempusr.HomeDir 20 wsPath := tempHome + "/tmpcnavrlws" 21 // NOT writing a workspace path 22 23 // no project name 24 expect := errors.New("No project name specified") 25 actual := OpenCode("", wsPath) 26 if expect.Error() != actual.Error() { 27 t.Errorf("Empty project name did not yield correct error") 28 t.Errorf("expected: %s\n", expect) 29 t.Errorf("actual: %s\n", actual) 30 return 31 } 32 expect = errors.New("No canaveral workspace set") 33 actual = OpenCode("FakeProject", wsPath) 34 if expect.Error() != actual.Error() { 35 t.Errorf("No workspace set did not yield correct error") 36 t.Errorf("expected: %s\n", expect) 37 t.Errorf("actual: %s\n", actual) 38 return 39 } 40 }