@@ -25,6 +25,12 @@ func TestAppsList(t *testing.T) {
2525 t .Fatal (err )
2626 }
2727 defer server .Close ()
28+
29+ // Set workspace in config so AppsList can read it
30+ s , _ := settings .Load (cf )
31+ s .Workspace = "dolar-sit-amet"
32+ cf , _ = s .Save (cf )
33+
2834 var b bytes.Buffer
2935 cmdr := DryccCmd {WOut : & b , ConfigFile : cf }
3036
@@ -38,7 +44,7 @@ func TestAppsList(t *testing.T) {
3844 {
3945 "uuid": "c4aed81c-d1ca-4ff1-ab89-d2151264e1a3",
4046 "id": "lorem-ipsum",
41- "owner ": "dolar-sit-amet",
47+ "workspace ": "dolar-sit-amet",
4248 "created": "2016-08-22T17:40:16Z",
4349 "updated": "2016-08-22T17:40:16Z",
4450 "structure": {
@@ -48,7 +54,7 @@ func TestAppsList(t *testing.T) {
4854 {
4955 "uuid": "c4aed81c-d1ca-4ff1-ab89-d2151264e1a3",
5056 "id": "consectetur",
51- "owner ": "adipiscing",
57+ "workspace ": "adipiscing",
5258 "created": "2016-08-22T17:40:16Z",
5359 "updated": "2016-08-22T17:40:16Z",
5460 "structure": {
@@ -61,19 +67,46 @@ func TestAppsList(t *testing.T) {
6167
6268 err = cmdr .AppsList (- 1 )
6369 assert .NoError (t , err )
64- testutil .AssertOutput (t , b .String (), `ID OWNER CREATED UPDATED
70+ testutil .AssertOutput (t , b .String (), `ID WORKSPACE CREATED UPDATED
6571lorem-ipsum dolar-sit-amet 2016-08-22T17:40:16Z 2016-08-22T17:40:16Z
6672consectetur adipiscing 2016-08-22T17:40:16Z 2016-08-22T17:40:16Z
6773` )
6874}
6975
76+ func TestAppsListNoWorkspace (t * testing.T ) {
77+ t .Parallel ()
78+ cf , _ , err := testutil .NewTestServerAndClient ()
79+ if err != nil {
80+ t .Fatal (err )
81+ }
82+
83+ // Clear workspace from config
84+ s , _ := settings .Load (cf )
85+ s .Workspace = ""
86+ cf , _ = s .Save (cf )
87+
88+ var b bytes.Buffer
89+ cmdr := DryccCmd {WOut : & b , ConfigFile : cf }
90+
91+ // When no default workspace in config, should return error
92+ err = cmdr .AppsList (- 1 )
93+ assert .Error (t , err )
94+ assert .Contains (t , err .Error (), "no workspace specified" )
95+ }
96+
7097func TestAppsListLimit (t * testing.T ) {
7198 t .Parallel ()
7299 cf , server , err := testutil .NewTestServerAndClient ()
73100 if err != nil {
74101 t .Fatal (err )
75102 }
76103 defer server .Close ()
104+
105+ // Set workspace in config so AppsList can read it
106+ s , _ := settings .Load (cf )
107+ s .Workspace = "dolar-sit-amet"
108+ cf , _ = s .Save (cf )
109+
77110 var b bytes.Buffer
78111 cmdr := DryccCmd {WOut : & b , ConfigFile : cf }
79112
@@ -87,7 +120,7 @@ func TestAppsListLimit(t *testing.T) {
87120 {
88121 "uuid": "c4aed81c-d1ca-4ff1-ab89-d2151264e1a3",
89122 "id": "lorem-ipsum",
90- "owner ": "dolar-sit-amet",
123+ "workspace ": "dolar-sit-amet",
91124 "created": "2016-08-22T17:40:16Z",
92125 "updated": "2016-08-22T17:40:16Z",
93126 "structure": {
@@ -100,7 +133,7 @@ func TestAppsListLimit(t *testing.T) {
100133
101134 err = cmdr .AppsList (1 )
102135 assert .NoError (t , err )
103- testutil .AssertOutput (t , b .String (), `ID OWNER CREATED UPDATED
136+ testutil .AssertOutput (t , b .String (), `ID WORKSPACE CREATED UPDATED
104137lorem-ipsum dolar-sit-amet 2016-08-22T17:40:16Z 2016-08-22T17:40:16Z
105138` )
106139}
@@ -120,7 +153,7 @@ func TestAppsInfo(t *testing.T) {
120153 fmt .Fprintf (w , `{
121154 "uuid": "c4aed81c-d1ca-4ff1-ab89-d2151264e1a3",
122155 "id": "lorem-ipsum",
123- "owner ": "dolar-sit-amet",
156+ "workspace ": "dolar-sit-amet",
124157 "structure": {
125158 "cmd": 1
126159 },
@@ -189,7 +222,7 @@ func TestAppsInfo(t *testing.T) {
189222 testutil .AssertOutput (t , b .String (), `App: lorem-ipsum
190223URL: ` + url + `
191224UUID: c4aed81c-d1ca-4ff1-ab89-d2151264e1a3
192- Owner: dolar-sit-amet
225+ Workspace: dolar-sit-amet
193226Created: 2016-08-22T17:40:16Z
194227Updated: 2016-08-22T17:40:16Z
195228Processes:
@@ -223,7 +256,7 @@ func TestAppDestroy(t *testing.T) {
223256 fmt .Fprintf (w , `{
224257 "uuid": "c4aed81c-d1ca-4ff1-ab89-d2151264e1a3",
225258 "id": "lorem-ipsum",
226- "owner ": "dolar-sit-amet",
259+ "workspace ": "dolar-sit-amet",
227260 "structure": {
228261 "cmd": 1
229262 },
@@ -256,7 +289,7 @@ func TestAppTransfer(t *testing.T) {
256289 fmt .Fprintf (w , `{
257290 "uuid": "c4aed81c-d1ca-4ff1-ab89-d2151264e1a3",
258291 "id": "lorem-ipsum",
259- "owner ": "dolar-sit-amet",
292+ "workspace ": "dolar-sit-amet",
260293 "structure": {
261294 "cmd": 1
262295 },
@@ -271,34 +304,18 @@ func TestAppTransfer(t *testing.T) {
271304` , "output" )
272305}
273306
274- func TestExpandUrl (t * testing.T ) {
275- checks := []expandURLCases {
276- {
277- Input : "test.com" ,
278- Expected : "test.com" ,
279- },
280- {
281- Input : "test" ,
282- Expected : "test.foo.com" ,
283- },
284- }
285-
286- for _ , check := range checks {
287- out := expandURL ("drycc.foo.com" , check .Input )
288-
289- if out != check .Expected {
290- t .Errorf ("Expected %s, Got %s" , check .Expected , out )
291- }
292- }
293- }
294-
295307func TestRemoteExists (t * testing.T ) {
296308 cf , server , err := testutil .NewTestServerAndClient ()
297309 if err != nil {
298310 t .Fatal (err )
299311 }
300312 defer server .Close ()
301313
314+ // Set workspace in config so AppCreate can read it
315+ s , _ := settings .Load (cf )
316+ s .Workspace = "test-workspace"
317+ cf , _ = s .Save (cf )
318+
302319 server .Mux .HandleFunc ("/v2/apps/" , func (w http.ResponseWriter , _ * http.Request ) {
303320 testutil .SetHeaders (w )
304321 fmt .Fprintf (w , `{
@@ -329,6 +346,6 @@ func TestRemoteExists(t *testing.T) {
329346 // Check that an error occurred and it contains the remote name
330347 // This works for any language since the remote name "drycc" is always in the error
331348 assert .Error (t , err )
332- assert .Contains (t , err .Error (), "drycc" ,
349+ assert .Contains (t , err .Error (), "drycc" ,
333350 "error message should contain the remote name 'drycc', got: %s" , err .Error ())
334351}
0 commit comments