Skip to content

Commit 981be31

Browse files
author
Ryan Svihla
committed
updating code coverage to be accurate
1 parent 1913014 commit 981be31

19 files changed

+300
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Apache 2.0 licensed Astra Cloud Management CLI
66
[![Go Report Card](https://goreportcard.com/badge/github.com/rsds143/astra-cli)](https://goreportcard.com/report/github.com/rsds143/astra-cli)
77
[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/rsds143/astra-cli)](https://img.shields.io/github/go-mod/go-version/rsds143/astra-cli)
88
[![Latest Version](https://img.shields.io/github/v/release/rsds143/astra-cli?include_prereleases)](https://github.com/rsds143/astra-cli/releases)
9-
<a href='https://github.com/jpoles1/gopherbadger' target='_blank'>![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-86%25-brightgreen.svg?longCache=true&style=flat)</a>
9+
<a href='https://github.com/jpoles1/gopherbadger' target='_blank'>![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-63%25-brightgreen.svg?longCache=true&style=flat)</a>
1010

1111
## status
1212

cmd/db.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//Package cmd contains all fo the commands for the cli
1516
package cmd
1617

1718
import (

cmd/db/create_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db
17+
18+
import "testing"
19+
20+
func TestCreate(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/db/delete.go

+17-10
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,25 @@ var DeleteCmd = &cobra.Command{
3030
Long: `deletes a database from your Astra account by ID`,
3131
Args: cobra.ExactArgs(1),
3232
Run: func(cmd *cobra.Command, args []string) {
33-
creds := &pkg.Creds{}
34-
client, err := creds.Login()
33+
msg, err := execteDelete(args)
3534
if err != nil {
36-
fmt.Fprintf(os.Stderr, "unable to login with error %v\n", err)
35+
fmt.Fprintln(os.Stderr, err)
3736
os.Exit(1)
3837
}
39-
id := args[0]
40-
fmt.Printf("starting to delete database %v\n", id)
41-
if err := client.Terminate(id, false); err != nil {
42-
fmt.Fprintln(os.Stderr, fmt.Errorf("unable to delete '%s' with error %v", id, err))
43-
os.Exit(1)
44-
}
45-
fmt.Printf("database %v deleted\n", id)
38+
fmt.Fprintln(os.Stdout, msg)
4639
},
4740
}
41+
42+
func execteDelete(args []string) (string, error) {
43+
creds := &pkg.Creds{}
44+
client, err := creds.Login()
45+
if err != nil {
46+
return "", fmt.Errorf("unable to login with error '%v'", err)
47+
}
48+
id := args[0]
49+
fmt.Printf("starting to delete database %v\n", id)
50+
if err := client.Terminate(id, false); err != nil {
51+
return "", fmt.Errorf("unable to delete '%s' with error %v", id, err)
52+
}
53+
return fmt.Sprintf("database %v deleted", id), nil
54+
}

cmd/db/delete_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db
17+
18+
import "testing"
19+
20+
func TestDelete(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/db/get_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db
17+
18+
import "testing"
19+
20+
func TestGet(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/db/list_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db

cmd/db/park_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db
17+
18+
import "testing"
19+
20+
func TestPark(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/db/resize_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db
17+
18+
import "testing"
19+
20+
func TestResize(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/db/secBundle_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db
17+
18+
import "testing"
19+
20+
func TestSecBundle(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/db/tiers_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db
17+
18+
import "testing"
19+
20+
func TestTiers(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/db/unpark_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package db is where the Astra DB commands are
16+
package db
17+
18+
import "testing"
19+
20+
func TestUnpark(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/db_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package cmd contains all fo the commands for the cli
16+
package cmd
17+
18+
import "testing"
19+
20+
func TestDbCmd(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/login.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//Package cmd is the entry point for all of the commands
1516
package cmd
1617

1718
import (

cmd/login_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package cmd contains all fo the commands for the cli
16+
package cmd
17+
18+
import "testing"
19+
20+
func TestLoginCmd(t *testing.T) {
21+
t.Skip("ignore")
22+
}

cmd/root.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ var RootCmd = &cobra.Command{
3636
Long: `Manage and provision databases on DataStax Astra
3737
Complete documentation is available at https://github.com/rsds143/astra-cli`,
3838
Run: func(cobraCmd *cobra.Command, args []string) {
39-
if err := cobraCmd.Usage(); err != nil {
40-
fmt.Printf("warn unable to show usage %v\n", err)
39+
if err := executeRoot(cobraCmd.Usage); err != nil {
4140
os.Exit(1)
4241
}
4342
},
4443
}
44+
45+
func executeRoot(usage func() error) error {
46+
if err := usage(); err != nil {
47+
return fmt.Errorf("warn unable to show usage %v", err)
48+
}
49+
return nil
50+
}

cmd/root_test.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2021 Ryan Svihla
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+
15+
//Package cmd contains all fo the commands for the cli
16+
package cmd
17+
18+
import (
19+
"errors"
20+
"testing"
21+
)
22+
23+
func TestUsageFails(t *testing.T) {
24+
fails := func() error {
25+
return errors.New("error showing usage")
26+
}
27+
err := executeRoot(fails)
28+
if err == nil {
29+
t.Fatal("there is supposed to be an error")
30+
}
31+
expected := "warn unable to show usage error showing usage"
32+
if err.Error() != expected {
33+
t.Errorf("expected '%v' but was '%v'", expected, err.Error())
34+
}
35+
}

coverage.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<a href='https://github.com/jpoles1/gopherbadger' target='_blank'>![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-86%25-brightgreen.svg?longCache=true&style=flat)</a>
1+
<a href='https://github.com/jpoles1/gopherbadger' target='_blank'>![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-63%25-brightgreen.svg?longCache=true&style=flat)</a>

coverage_badge.png

-15 Bytes
Loading

0 commit comments

Comments
 (0)