@@ -58,28 +58,57 @@ func TestDescribeProjectCmd(t *testing.T) {
5858				return  false 
5959			}),
6060		},
61- 		"error missing revision/version" : {
61+ 		"error missing revision/version/branch/tag " : {
6262			options : describeProjectOptions {
6363				ProjectID : "test-project" ,
6464			},
6565			expectError :      true ,
66- 			expectedErrorMsg : "missing revision/version name, please provide one as argument" ,
66+ 			expectedErrorMsg : "missing revision/version/branch/tag  name, please provide one as argument" ,
6767			testServer : describeTestServer (t , func (_  http.ResponseWriter , _  * http.Request ) bool  {
6868				return  false 
6969			}),
7070		},
71- 		"error both  revision/version specified" : {
71+ 		"error multiple  revision/version specified" : {
7272			options : describeProjectOptions {
7373				ProjectID :    "test-project" ,
7474				RevisionName : "test-revision" ,
7575				VersionName :  "test-version" ,
7676			},
7777			expectError :      true ,
78- 			expectedErrorMsg : "both revision and version  specified, please provide only one" ,
78+ 			expectedErrorMsg : "multiple identifiers  specified, please provide only one" ,
7979			testServer : describeTestServer (t , func (_  http.ResponseWriter , _  * http.Request ) bool  {
8080				return  false 
8181			}),
8282		},
83+ 		"error multiple branch/revision specified" : {
84+ 			options : describeProjectOptions {
85+ 				ProjectID :    "test-project" ,
86+ 				RevisionName : "test-revision" ,
87+ 				BranchName :   "test-branch" ,
88+ 			},
89+ 			expectError :      true ,
90+ 			expectedErrorMsg : "multiple identifiers specified, please provide only one" ,
91+ 			testServer : describeTestServer (t , func (_  http.ResponseWriter , _  * http.Request ) bool  {
92+ 				return  false 
93+ 			}),
94+ 		},
95+ 		"valid project with branch" : {
96+ 			options : describeProjectOptions {
97+ 				ProjectID :    "test-project" ,
98+ 				BranchName :   "test-json-branch" ,
99+ 				OutputFormat : "json" ,
100+ 			},
101+ 			revisionName : "test-revision" ,
102+ 			testServer : describeTestServer (t , func (w  http.ResponseWriter , r  * http.Request ) bool  {
103+ 				if  r .URL .Path  ==  "/api/backend/projects/test-project/branches/test-json-branch/configuration/"  &&  r .Method  ==  http .MethodGet  {
104+ 					w .WriteHeader (http .StatusOK )
105+ 					_ , _  =  w .Write ([]byte (`{"name": "test-project", "branch": "test-json-branch"}` ))
106+ 					return  true 
107+ 				}
108+ 				return  false 
109+ 			}),
110+ 			outputTextJSON : `{"config": {"name": "test-project", "branch": "test-json-branch"}}` ,
111+ 		},
83112		"valid project with revision" : {
84113			options : describeProjectOptions {
85114				ProjectID :    "test-project" ,
@@ -88,7 +117,7 @@ func TestDescribeProjectCmd(t *testing.T) {
88117			},
89118			revisionName : "test-revision" ,
90119			testServer : describeTestServer (t , func (w  http.ResponseWriter , r  * http.Request ) bool  {
91- 				if  r .URL .Path  ==  "/api/backend/projects/test-project/revisions/test-json-revision/configuration"  &&  r .Method  ==  http .MethodGet  {
120+ 				if  r .URL .Path  ==  "/api/backend/projects/test-project/revisions/test-json-revision/configuration/ "  &&  r .Method  ==  http .MethodGet  {
92121					w .WriteHeader (http .StatusOK )
93122					_ , _  =  w .Write ([]byte (`{"name": "test-project", "revision": "test-json-revision"}` ))
94123					return  true 
@@ -97,14 +126,30 @@ func TestDescribeProjectCmd(t *testing.T) {
97126			}),
98127			outputTextJSON : `{"config": {"name": "test-project", "revision": "test-json-revision"}}` ,
99128		},
129+ 		"valid project with tag" : {
130+ 			options : describeProjectOptions {
131+ 				ProjectID :    "test-project" ,
132+ 				TagName :      "test-tag" ,
133+ 				OutputFormat : "json" ,
134+ 			},
135+ 			testServer : describeTestServer (t , func (w  http.ResponseWriter , r  * http.Request ) bool  {
136+ 				if  r .URL .Path  ==  "/api/backend/projects/test-project/branches/test-tag/configuration/"  &&  r .Method  ==  http .MethodGet  {
137+ 					w .WriteHeader (http .StatusOK )
138+ 					_ , _  =  w .Write ([]byte (`{"name": "test-project", "tag": "test-tag"}` ))
139+ 					return  true 
140+ 				}
141+ 				return  false 
142+ 			}),
143+ 			outputTextJSON : `{"config": {"name": "test-project", "tag": "test-tag"}}` ,
144+ 		},
100145		"valid project with version" : {
101146			options : describeProjectOptions {
102147				ProjectID :    "test-project" ,
103148				VersionName :  "test-version" ,
104149				OutputFormat : "json" ,
105150			},
106151			testServer : describeTestServer (t , func (w  http.ResponseWriter , r  * http.Request ) bool  {
107- 				if  r .URL .Path  ==  "/api/backend/projects/test-project/versions/test-version/configuration"  &&  r .Method  ==  http .MethodGet  {
152+ 				if  r .URL .Path  ==  "/api/backend/projects/test-project/versions/test-version/configuration/ "  &&  r .Method  ==  http .MethodGet  {
108153					w .WriteHeader (http .StatusOK )
109154					_ , _  =  w .Write ([]byte (`{"name": "test-project", "revision": "test-version"}` ))
110155					return  true 
@@ -120,7 +165,7 @@ func TestDescribeProjectCmd(t *testing.T) {
120165				OutputFormat : "yaml" ,
121166			},
122167			testServer : describeTestServer (t , func (w  http.ResponseWriter , r  * http.Request ) bool  {
123- 				if  r .URL .Path  ==  "/api/backend/projects/test-project/revisions/test-yaml-revision/configuration"  &&  r .Method  ==  http .MethodGet  {
168+ 				if  r .URL .Path  ==  "/api/backend/projects/test-project/revisions/test-yaml-revision/configuration/ "  &&  r .Method  ==  http .MethodGet  {
124169					w .WriteHeader (http .StatusOK )
125170					_ , _  =  w .Write ([]byte (`{"name": "test-project", "revision": "test-yaml-revision"}` ))
126171					return  true 
@@ -136,7 +181,7 @@ func TestDescribeProjectCmd(t *testing.T) {
136181				OutputFormat : "yaml" ,
137182			},
138183			testServer : describeTestServer (t , func (w  http.ResponseWriter , r  * http.Request ) bool  {
139- 				if  r .URL .Path  ==  "/api/backend/projects/test-project/revisions/some%2Frevision/configuration"  &&  r .Method  ==  http .MethodGet  {
184+ 				if  r .URL .Path  ==  "/api/backend/projects/test-project/revisions/some%2Frevision/configuration/ "  &&  r .Method  ==  http .MethodGet  {
140185					w .WriteHeader (http .StatusOK )
141186					_ , _  =  w .Write ([]byte (`{"name": "test-project", "revision": "test-yaml-revision"}` ))
142187					return  true 
@@ -152,7 +197,7 @@ func TestDescribeProjectCmd(t *testing.T) {
152197				OutputFormat : "yaml" ,
153198			},
154199			testServer : describeTestServer (t , func (w  http.ResponseWriter , r  * http.Request ) bool  {
155- 				if  r .URL .Path  ==  "/api/backend/projects/test-project/versions/version%2F1.2.3/configuration"  &&  r .Method  ==  http .MethodGet  {
200+ 				if  r .URL .Path  ==  "/api/backend/projects/test-project/versions/version%2F1.2.3/configuration/ "  &&  r .Method  ==  http .MethodGet  {
156201					w .WriteHeader (http .StatusOK )
157202					_ , _  =  w .Write ([]byte (`{"name": "test-project", "revision": "test-yaml-revision"}` ))
158203					return  true 
0 commit comments