Skip to content

Commit 9b0b4c6

Browse files
authored
Merge pull request #46 from dimitraz/cli-tests
Update docs & test coverage
2 parents 51dc6d1 + 472d777 commit 9b0b4c6

22 files changed

+383
-66
lines changed

cmd/mobile/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
1+
// Copyright Red Hat, Inc., and individual contributors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

pkg/cmd/base.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import "github.com/aerogear/mobile-cli/pkg/cmd/output"

pkg/cmd/clientBuild.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import "github.com/spf13/cobra"

pkg/cmd/clientBuild_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (

pkg/cmd/clientConfig.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
1+
// Copyright Red Hat, Inc., and individual contributors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

pkg/cmd/clientConfig_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (

pkg/cmd/clients.go

+30-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (
@@ -31,10 +45,10 @@ func (cc *ClientCmd) ListClientsCmd() *cobra.Command {
3145
command := &cobra.Command{
3246
Use: "clients",
3347
Short: "gets a list of mobile clients represented in the namespace",
34-
Long: `Example: mobile get clients
35-
mobile --namespace=myproject get clients
36-
kubectl plugin mobile get clients
37-
oc plugin mobile get clients`,
48+
Long: `get clients allows you to get a list of mobile clients that are represented in your namespace.`,
49+
Example: ` mobile get clients --namespace=myproject
50+
kubectl plugin mobile get clients
51+
oc plugin mobile get clients`,
3852
RunE: func(cmd *cobra.Command, args []string) error {
3953
ns, err := currentNamespace(cmd.Flags())
4054
if err != nil {
@@ -71,9 +85,11 @@ func (cc *ClientCmd) GetClientCmd() *cobra.Command {
7185
command := &cobra.Command{
7286
Use: "client <clientID>",
7387
Short: "gets a single mobile client in the namespace",
74-
Long: `Example: mobile --namespace=myproject get client <clientID>
75-
kubectl plugin mobile get client <clientID>
76-
oc plugin mobile get client <clientID>`,
88+
Long: `get client allows you to view client information for a specific mobile client in your namespace.
89+
Run the "mobile get clients" command from this tool to get the client ID.`,
90+
Example: ` mobile get client <clientID> --namespace=myproject
91+
kubectl plugin mobile get client <clientID>
92+
oc plugin mobile get client <clientID>`,
7793
RunE: func(cmd *cobra.Command, args []string) error {
7894
if len(args) != 1 {
7995
return errors.New("missing argument <clientID>")
@@ -112,7 +128,7 @@ func (cc *ClientCmd) CreateClientCmd() *cobra.Command {
112128
cmd := &cobra.Command{
113129
Use: "client <name> <clientType iOS|cordova|android> <appIdentifier bundleID|packageName >",
114130
Short: "create a mobile client representation in your namespace",
115-
Long: `Sets up the representation of a mobile application of the specified type in your namespace.
131+
Long: `create client sets up the representation of a mobile application of the specified type in your namespace.
116132
This is used to provide a mobile client context for various actions such as creating, starting or stopping mobile client builds.
117133
118134
The available client types are android, cordova and iOS.
@@ -121,6 +137,7 @@ When used standalone, a namespace must be specified by providing the --namespace
121137
Example: ` mobile create client <name> <clientType> <appIdentifier> --namespace=myproject
122138
kubectl plugin mobile create client <name> <clientType> <appIdentifier>
123139
oc plugin mobile create client <name> <clientType> <appIdentifier>`,
140+
124141
RunE: func(cmd *cobra.Command, args []string) error {
125142
if len(args) != 3 {
126143
return errors.New("expected a name a clientType and a appIdentifier")
@@ -190,9 +207,11 @@ func (cc *ClientCmd) DeleteClientCmd() *cobra.Command {
190207
command := &cobra.Command{
191208
Use: "client <clientID>",
192209
Short: "deletes a single mobile client in the namespace",
193-
Long: `Example: mobile --namespace=myproject delete client <clientID>
194-
kubectl plugin mobile delete client <clientID>
195-
oc plugin mobile delete client <clientID>`,
210+
Long: `delete client allows you to delete a single mobile client in your namespace.
211+
Run the "mobile get clients" command from this tool to get the client ID.`,
212+
Example: ` mobile delete client <clientID> --namespace=myproject
213+
kubectl plugin mobile delete client <clientID>
214+
oc plugin mobile delete client <clientID>`,
196215
RunE: func(cmd *cobra.Command, args []string) error {
197216
var err error
198217
var ns string

pkg/cmd/clients_test.go

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd_test
216

317
import (
@@ -19,7 +33,7 @@ import (
1933
kt "k8s.io/client-go/testing"
2034
)
2135

22-
func TestListClients(t *testing.T) {
36+
func TestMobileClientsCmd_TestListClients(t *testing.T) {
2337
cases := []struct {
2438
Name string
2539
MobileClient func() mc.Interface
@@ -97,7 +111,7 @@ func TestListClients(t *testing.T) {
97111
}
98112
}
99113

100-
func TestGetClient(t *testing.T) {
114+
func TestMobileClientsCmd_TestGetClient(t *testing.T) {
101115
cases := []struct {
102116
Name string
103117
ClientName string
@@ -195,15 +209,14 @@ func TestGetClient(t *testing.T) {
195209
}
196210
}
197211

198-
func TestDeleteClient(t *testing.T) {
212+
func TestMobileClientsCmd_TestDeleteClient(t *testing.T) {
199213
cases := []struct {
200214
Name string
201215
ClientName string
202216
MobileClient func() mc.Interface
203217
ExpectError bool
204218
ErrorPattern string
205219
Flags []string
206-
Validate func(t *testing.T, c *v1alpha1.MobileClient)
207220
}{
208221
{
209222
Name: "test delete client succeeds with no errors",
@@ -220,7 +233,6 @@ func TestDeleteClient(t *testing.T) {
220233
mc := &mcFake.Clientset{}
221234
return mc
222235
},
223-
224236
Flags: []string{"--namespace=myproject", "-o=json"},
225237
ExpectError: true,
226238
},
@@ -233,7 +245,6 @@ func TestDeleteClient(t *testing.T) {
233245
})
234246
return mc
235247
},
236-
237248
Flags: []string{"--namespace=myproject", "-o=json"},
238249
ExpectError: true,
239250
},
@@ -254,7 +265,6 @@ func TestDeleteClient(t *testing.T) {
254265
args = append(args, tc.ClientName)
255266
}
256267
err := deleteClient.RunE(deleteClient, args)
257-
258268
if tc.ExpectError && err == nil {
259269
t.Fatal("expected an error but got none")
260270
}
@@ -266,12 +276,11 @@ func TestDeleteClient(t *testing.T) {
266276
t.Fatal("expected the error to match the pattern "+tc.ErrorPattern, err)
267277
}
268278
}
269-
270279
})
271280
}
272281
}
273282

274-
func TestCreateClient(t *testing.T) {
283+
func TestMobileClientsCmd_TestCreateClient(t *testing.T) {
275284
cases := []struct {
276285
Name string
277286
Args []string
@@ -479,7 +488,6 @@ func TestCreateClient(t *testing.T) {
479488
}
480489
tc.Validate(t, mobileClient)
481490
}
482-
483491
})
484492
}
485493
}

pkg/cmd/convert.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (

pkg/cmd/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
1+
// Copyright Red Hat, Inc., and individual contributors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

pkg/cmd/delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
1+
// Copyright Red Hat, Inc., and individual contributors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

pkg/cmd/get.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
1+
// Copyright Red Hat, Inc., and individual contributors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

pkg/cmd/input/validate.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package input
216

317
import (

pkg/cmd/integration.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (

pkg/cmd/output/renderer.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright Red Hat, Inc., and individual contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package output
216

317
import (

pkg/cmd/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
1+
// Copyright Red Hat, Inc., and individual contributors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

pkg/cmd/serviceConfig.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
1+
// Copyright Red Hat, Inc., and individual contributors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)