Skip to content

Commit

Permalink
#146 Passed checks
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed May 29, 2024
1 parent 4269f55 commit abb0c98
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ go.work

# Makefile
target/

cover.out
coverage.html
49 changes: 49 additions & 0 deletions .testcoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# (mandatory)
# Path to coverprofile file (output of `go test -coverprofile` command).
#
# For cases where there are many coverage profiles, such as when running
# unit tests and integration tests separately, you can combine all those
# profiles into one. In this case, the profile should have a comma-separated list
# of profile files, e.g., 'cover_unit.out,cover_integration.out'.
profile: cover.out

# (optional; but recommended to set)
# When specified reported file paths will not contain local prefix in the output
local-prefix: "github.com/org/project"

# Holds coverage thresholds percentages, values should be in range [0-100]
threshold:
# (optional; default 0)
# The minimum coverage that each file should have
file: 70

# (optional; default 0)
# The minimum coverage that each package should have
package: 70

# (optional; default 0)
# The minimum total coverage project should have
total: 70
# Holds regexp rules which will override thresholds for matched files or packages
# using their paths.
#
# First rule from this list that matches file or package is going to apply
# new threshold to it. If project has multiple rules that match same path,
# override rules should be listed in order from specific to more general rules.
#override:
# Increase coverage threshold to 100% for `foo` package
# (default is 80, as configured above in this example)
#- threshold: 100
# path: ^pkg/lib/foo$

# Holds regexp rules which will exclude matched files or packages
# from coverage statistics
#exclude:
# Exclude files or packages matching their paths
#paths:
# - \.pb\.go$ # excludes all protobuf generated files
# - ^pkg/bar # exclude package `pkg/bar`

# NOTES:
# - symbol `/` in all path regexps will be replaced by current OS file path separator
# to properly work on Windows
38 changes: 34 additions & 4 deletions cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,37 @@ import (
"testing"
)

/*
* The unit tests in this file simulate command line invocation.
*/
func TestMain(testing *testing.T) {}
func testError(err error) {
if err != nil {
panic(err)
}
}

func Test_Cmd(test *testing.T) {
_ = test
Execute()
}

func Test_RootCmd(test *testing.T) {
_ = test
err := RootCmd.Execute()
testError(err)
err = RootCmd.RunE(RootCmd, []string{})
testError(err)
}

func Test_completionCmd(test *testing.T) {
_ = test
err := completionCmd.Execute()
testError(err)
err = completionCmd.RunE(completionCmd, []string{})
testError(err)
}

func Test_docsCmd(test *testing.T) {
_ = test
err := docsCmd.Execute()
testError(err)
err = docsCmd.RunE(docsCmd, []string{})
testError(err)
}
2 changes: 2 additions & 0 deletions cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ To load completions automaticallon on login, add this line to your .bashrc file:
source < (template-go completion)
`,
RunE: func(cmd *cobra.Command, args []string) error {
_ = cmd
_ = args
return completionAction(os.Stdout)
},
}
Expand Down
1 change: 1 addition & 0 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var docsCmd = &cobra.Command{
Use: "docs",
Short: "Generate documentation for the command",
RunE: func(cmd *cobra.Command, args []string) error {
_ = args
dir, err := cmd.Flags().GetString("dir")
if err != nil {
return err
Expand Down
14 changes: 7 additions & 7 deletions cmd/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
package cmd

var (
githubDate string = "2023-10-23"
githubIteration string = "0"
githubRef string = "refs/tags/0.2.4"
githubRefName string = "0.2.4"
githubRepository string = "Senzing/template-go"
githubRepositoryName string = "template-go"
githubVersion string = "0.2.4"
githubDate = "2023-10-23"
githubIteration = "0"
githubRef = "refs/tags/0.2.4"
githubRefName = "0.2.4"
githubRepository = "Senzing/template-go"
githubRepositoryName = "template-go"
githubVersion = "0.2.4"
)
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func PreRun(cobraCommand *cobra.Command, args []string) {
// Used in construction of cobra.Command
func RunE(_ *cobra.Command, _ []string) error {
ctx := context.Background()
examplePackage := &examplepackage.ExamplePackageImpl{
examplePackage := &examplepackage.ExampleImpl{
Something: viper.GetString(SomethingToSay.Arg),
}
return examplePackage.SaySomething(ctx)
Expand Down
10 changes: 7 additions & 3 deletions examplepackage/examplepackage_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ package examplepackage

import (
"context"
"fmt"
)

// ----------------------------------------------------------------------------
// Examples for godoc documentation
// ----------------------------------------------------------------------------

func ExampleExamplePackageImpl_SaySomething() {
func ExampleExampleImpl_SaySomething() {
// For more information, visit https://github.com/senzing-garage/template-go/blob/main/examplepackage/examplepackage_test.go
ctx := context.TODO()
examplePackage := &ExamplePackageImpl{
examplePackage := &ExampleImpl{
Something: "I'm here",
}
examplePackage.SaySomething(ctx)
err := examplePackage.SaySomething(ctx)
if err != nil {
fmt.Print(err)
}
//Output:
//examplePackage: I'm here
}
7 changes: 4 additions & 3 deletions examplepackage/examplepackage_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
// Types
// ----------------------------------------------------------------------------

// ExamplePackageImpl is an example type-struct.
type ExamplePackageImpl struct {
// ExampleImpl is an example type-struct.
type ExampleImpl struct {
Something string
}

Expand All @@ -34,7 +34,8 @@ Output
- Nothing is returned, except for an error. However, something is printed.
See the example output.
*/
func (examplepackage *ExamplePackageImpl) SaySomething(ctx context.Context) error {
func (examplepackage *ExampleImpl) SaySomething(ctx context.Context) error {
_ = ctx
fmt.Printf("%s: %s\n", exampleConstant, examplepackage.Something)
return nil
}
10 changes: 5 additions & 5 deletions examplepackage/examplepackage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// ----------------------------------------------------------------------------
Expand All @@ -28,12 +28,12 @@ func TestMain(m *testing.M) {
}

func setup() error {
var err error = nil
var err error
return err
}

func teardown() error {
var err error = nil
var err error
return err
}

Expand All @@ -43,9 +43,9 @@ func teardown() error {

func TestExamplePackageImpl_SaySomething(test *testing.T) {
ctx := context.TODO()
testObject := &ExamplePackageImpl{
testObject := &ExampleImpl{
Something: "I'm here",
}
err := testObject.SaySomething(ctx)
assert.Nil(test, err)
require.NoError(test, err)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10 h1:vpzMC/iZhYFAjJzHU0Cfuq+w1vLLsF2vLkDrPjzKYck=
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
Expand Down
8 changes: 3 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"testing"
)

/*
* The unit tests in this file simulate command line invocation.
*/
func TestMain(testing *testing.T) {
// main()
func TestMain(test *testing.T) {
_ = test
main()
}

0 comments on commit abb0c98

Please sign in to comment.