Skip to content

Commit

Permalink
Use _test suffix for tests and switch gatherer key name variable
Browse files Browse the repository at this point in the history
  • Loading branch information
rtorrero committed Nov 17, 2022
1 parent f278107 commit 9350954
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions internal/factsengine/gatherers/gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type FactGatherer interface {

func StandardGatherers() map[string]FactGatherer {
return map[string]FactGatherer{
CorosyncFactKey: NewDefaultCorosyncConfGatherer(),
HostsFileFactKey: NewDefaultHostsFileGatherer(),
CorosyncFactKey: NewDefaultCorosyncConfGatherer(),
HostsFileGathererName: NewDefaultHostsFileGatherer(),
}
}
10 changes: 5 additions & 5 deletions internal/factsengine/gatherers/hostsfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
)

const (
HostsFileFactKey = "hosts"
HostsFilePath = "/etc/hosts"
ipMatchGroup = "ip"
hostnamesMatchGroup = "hostnames"
parsingRegexp = `(?m)(?P<` + ipMatchGroup + `>\S+)\s+(?P<` + hostnamesMatchGroup + `>.+)`
HostsFileGathererName = "hosts"
HostsFilePath = "/etc/hosts"
ipMatchGroup = "ip"
hostnamesMatchGroup = "hostnames"
parsingRegexp = `(?m)(?P<` + ipMatchGroup + `>\S+)\s+(?P<` + hostnamesMatchGroup + `>.+)`
)

var (
Expand Down
9 changes: 5 additions & 4 deletions internal/factsengine/gatherers/hostsfile_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package gatherers
package gatherers_test

import (
"testing"

"github.com/stretchr/testify/suite"
"github.com/trento-project/agent/internal/factsengine/entities"
"github.com/trento-project/agent/internal/factsengine/gatherers"
"github.com/trento-project/agent/test/helpers"
)

Expand All @@ -17,7 +18,7 @@ func TestHostsFileTestSuite(t *testing.T) {
}

func (suite *HostsFileTestSuite) TestHostsFileBasic() {
c := NewHostsFileGatherer(helpers.GetFixturePath("gatherers/hosts.basic"))
c := gatherers.NewHostsFileGatherer(helpers.GetFixturePath("gatherers/hosts.basic"))

factRequests := []entities.FactRequest{
{
Expand Down Expand Up @@ -107,7 +108,7 @@ func (suite *HostsFileTestSuite) TestHostsFileBasic() {
}

func (suite *HostsFileTestSuite) TestHostsFileNotExists() {
c := NewHostsFileGatherer("non_existing_file")
c := gatherers.NewHostsFileGatherer("non_existing_file")

factRequests := []entities.FactRequest{
{
Expand All @@ -125,7 +126,7 @@ func (suite *HostsFileTestSuite) TestHostsFileNotExists() {

func (suite *HostsFileTestSuite) TestHostsFileIgnoresCommentedHosts() {

c := NewHostsFileGatherer(helpers.GetFixturePath("gatherers/hosts.basic"))
c := gatherers.NewHostsFileGatherer(helpers.GetFixturePath("gatherers/hosts.basic"))

factRequests := []entities.FactRequest{
{
Expand Down

0 comments on commit 9350954

Please sign in to comment.