Skip to content

Commit

Permalink
removing unused packages and adding improving coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarsilva948 committed Sep 3, 2023
1 parent c43b2d9 commit 683559a
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 166 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ aftctl64.exe
.env

test
tests
cover.out
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ coverage:

.PHONY: install
install:
go install ./cmd/rosa
go install ./cmd/aftctl

.PHONY: fmt
fmt:
Expand Down
3 changes: 0 additions & 3 deletions cmd/aftctl/aftctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/edgarsilva948/aftctl/cmd/docs"
"github.com/edgarsilva948/aftctl/cmd/version"

"github.com/edgarsilva948/aftctl/pkg/arguments"
"github.com/edgarsilva948/aftctl/pkg/color"
)

Expand All @@ -30,9 +29,7 @@ var root = &cobra.Command{

func init() {
// Add the command line flags:
fs := root.PersistentFlags()
color.AddFlag(root)
arguments.AddDebugFlag(fs)

// Register the subcommands:
root.AddCommand(completion.Cmd)
Expand Down
5 changes: 0 additions & 5 deletions cmd/deploy/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package deploy

import (
"github.com/edgarsilva948/aftctl/cmd/deploy/aft"
"github.com/edgarsilva948/aftctl/pkg/arguments"
"github.com/spf13/cobra"
)

Expand All @@ -22,8 +21,4 @@ func init() {

Cmd.AddCommand(aft.Cmd)

flags := Cmd.PersistentFlags()
arguments.AddProfileFlag(flags)
arguments.AddRegionFlag(flags)

}
13 changes: 13 additions & 0 deletions cmd/deploy/deploy_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package deploy_test

import (
ginkgo "github.com/onsi/ginkgo/v2"
gomega "github.com/onsi/gomega"

"testing"
)

func TestDeploy(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "Deploy Suite")
}
35 changes: 35 additions & 0 deletions cmd/deploy/test_cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package deploy

import (
"github.com/edgarsilva948/aftctl/cmd/deploy/aft"

ginkgo "github.com/onsi/ginkgo/v2"
gomega "github.com/onsi/gomega"
)

var _ = ginkgo.Describe("Deploy Command", func() {

ginkgo.Context("Cmd", func() {
ginkgo.It("should have 'deploy' as the use field", func() {
gomega.Expect(Cmd.Use).To(gomega.Equal("deploy"))
})

ginkgo.It("should have a slice of aliases containing 'setup'", func() {
gomega.Expect(Cmd.Aliases).To(gomega.ConsistOf("setup"))
})

ginkgo.It("should have a short description", func() {
gomega.Expect(Cmd.Short).To(gomega.Equal("Deploy AFT from from stdin"))
})

ginkgo.It("should have a long description", func() {
gomega.Expect(Cmd.Long).To(gomega.Equal("Deploy AFT from from stdin"))
})

ginkgo.It("should register aft.Cmd as a subcommand", func() {
gomega.Expect(Cmd.HasSubCommands()).To(gomega.BeTrue())
gomega.Expect(Cmd.Commands()).To(gomega.ContainElement(aft.Cmd))
})
})

})
2 changes: 1 addition & 1 deletion deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
metadata:
name: "batata"
name: ""

deploymentConfiguration:
createTerraformStateBucket: true
Expand Down
26 changes: 0 additions & 26 deletions pkg/arguments/arguments.go

This file was deleted.

38 changes: 0 additions & 38 deletions pkg/aws/profile/flag.go

This file was deleted.

35 changes: 0 additions & 35 deletions pkg/aws/region/flag.go

This file was deleted.

13 changes: 13 additions & 0 deletions pkg/aws/tags/tags_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tags_test

import (
ginkgo "github.com/onsi/ginkgo/v2"
gomega "github.com/onsi/gomega"

"testing"
)

func TestTags(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "Tags Suite")
}
28 changes: 28 additions & 0 deletions pkg/aws/tags/test_tags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package tags

import (
ginkgo "github.com/onsi/ginkgo/v2"
gomega "github.com/onsi/gomega"
)

var _ = ginkgo.Describe("Tags", func() {

ginkgo.Context("When defining prefix", func() {
ginkgo.It("should have a prefix as 'created-by-'", func() {
gomega.Expect(prefix).To(gomega.Equal("created-by-"))
})
})

ginkgo.Context("When using Aftctl tag", func() {
ginkgo.It("should concatenate prefix and 'aftctl'", func() {
gomega.Expect(Aftctl).To(gomega.Equal("created-by-aftctl"))
})
})

ginkgo.Context("When using True constant", func() {
ginkgo.It("should be 'true'", func() {
gomega.Expect(True).To(gomega.Equal("true"))
})
})

})
13 changes: 13 additions & 0 deletions pkg/color/color_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package color_test

import (
ginkgo "github.com/onsi/ginkgo/v2"
gomega "github.com/onsi/gomega"

"testing"
)

func TestColor(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "Color Suite")
}
38 changes: 38 additions & 0 deletions pkg/color/test_flag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package color

import (
ginkgo "github.com/onsi/ginkgo/v2"
gomega "github.com/onsi/gomega"
"github.com/spf13/cobra"
)

var _ = ginkgo.Describe("Color", func() {

ginkgo.Describe("UseColor function", func() {
ginkgo.Context("when color option is 'never'", func() {
ginkgo.It("should return false", func() {
color = "never"
gomega.Expect(UseColor()).To(gomega.BeFalse())
})
})

ginkgo.Context("when color option is 'always'", func() {
ginkgo.It("should return true", func() {
color = "always"
gomega.Expect(UseColor()).To(gomega.BeTrue())
})
})
})

ginkgo.Describe("AddFlag function", func() {
var cmd *cobra.Command
ginkgo.BeforeEach(func() {
cmd = &cobra.Command{}
AddFlag(cmd)
})

ginkgo.It("should add a 'color' flag", func() {
gomega.Expect(cmd.PersistentFlags().Lookup("color")).To(gomega.Not(gomega.BeNil()))
})
})
})
29 changes: 0 additions & 29 deletions pkg/debug/flag.go

This file was deleted.

28 changes: 0 additions & 28 deletions pkg/helper/helpers.go

This file was deleted.

13 changes: 13 additions & 0 deletions pkg/info/info_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package info_test

import (
ginkgo "github.com/onsi/ginkgo/v2"
gomega "github.com/onsi/gomega"

"testing"
)

func TestInfo(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "Info Suite")
}
Loading

0 comments on commit 683559a

Please sign in to comment.