Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Schmidt committed Dec 15, 2023
1 parent b0a6905 commit ed5cd65
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 377 deletions.
1 change: 0 additions & 1 deletion .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ jobs:
with:
version: v1.50
args: --timeout=5m

10 changes: 6 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Tests
on:
push:
branches:
- '*'
- "*"
tags:
- v*
workflow_call:

jobs:
tests:
runs-on: ubuntu-latest
Expand All @@ -24,7 +26,7 @@ jobs:
- name: Generate Mocks
run: |
make mocks
- name: Test with go
- name: Test with go
env:
TEST_SCHEMA_DIR: ${{ env.CWD }}/schemas/json/aerospike
run: |
Expand All @@ -34,4 +36,4 @@ jobs:
with:
token: ${{secrets.CODECOV_TOKEN}}
files: coverage.cov
verbose: false
verbose: false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea
*_mock.go
.vscode
*.cov
*.cov
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ else
GOBIN=$(shell go env GOBIN)
endif

MOCKGEN = $(GOBIN)/mockgen
MOCKGEN ?= $(GOBIN)/mockgen
MOCKGEN_VERSION ?= v0.3.0
GOLANGCI_LINT ?= $(GOBIN)/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.50.1

Expand All @@ -17,8 +18,13 @@ $(GOLANGCI_LINT): $(GOBIN)
go-lint: golanci-lint ## Run golangci-lint against code.
$(GOLANGCI_LINT) run

.PHONY: get-mockgen
get-mockgen: $(MOCKGEN) ## Download golangci-lint locally if necessary.
$(MOCKGEN): $(GOBIN)
go install go.uber.org/mock/mockgen@$(MOCKGEN_VERSION)

.PHONY: mocks
mocks: $(MOCKGEN)
mocks: get-mockgen
$(MOCKGEN) --source info/as_parser.go --destination info/as_parser_mock.go --package info
$(MOCKGEN) --source asconfig/generate.go --destination asconfig/generate_mock.go --package asconfig

Expand All @@ -40,4 +46,4 @@ clean-mocks:

.PHONY: clean
clean: clean-mocks
rm coverage.cov
rm coverage.cov
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ It provides the following components
- [Aerospike configuration](asconfig) - functions for validation and converting Aerospike server configuration to and from YAML.
- [Deployment](deployment) - functions for inspecting and running administration calls on Aerospike clusters.
- [Info](info) - function to run [info](https://docs.aerospike.com/docs/tools/asinfo/index.html) commands on Aerospike clusters.


24 changes: 12 additions & 12 deletions asconfig/asconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/go-logr/logr"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
"go.uber.org/mock/gomock"
)

type AsConfigTestSuite struct {
Expand All @@ -14,12 +14,12 @@ type AsConfigTestSuite struct {
ctrl *gomock.Controller
}

func (suite *AsConfigTestSuite) SetupTest() {
suite.ctrl = gomock.NewController(suite.T())
suite.mockGetter = NewMockConfGetter(suite.ctrl)
func (s *AsConfigTestSuite) SetupTest() {
s.ctrl = gomock.NewController(s.T())
s.mockGetter = NewMockConfGetter(s.ctrl)
}

func (suite *AsConfigTestSuite) TestAsConfigGetFlatMap() {
func (s *AsConfigTestSuite) TestAsConfigGetFlatMap() {
testCases := []struct {
name string
version string
Expand Down Expand Up @@ -78,19 +78,19 @@ func (suite *AsConfigTestSuite) TestAsConfigGetFlatMap() {
}

for _, tc := range testCases {
suite.Run(tc.name, func() {
s.Run(tc.name, func() {
logger := logr.Discard()

asConfig, err := NewMapAsConfig(logger, tc.version, tc.inputMap)
actual := asConfig.GetFlatMap()

suite.Assert().Nil(err)
suite.Assert().Equal(tc.expected, actual)
s.Assert().Nil(err)
s.Assert().Equal(tc.expected, actual)
})
}
}

func (suite *AsConfigTestSuite) TestAsConfigGetExpandMap() {
func (s *AsConfigTestSuite) TestAsConfigGetExpandMap() {
testCases := []struct {
name string
version string
Expand Down Expand Up @@ -364,14 +364,14 @@ func (suite *AsConfigTestSuite) TestAsConfigGetExpandMap() {
}

for _, tc := range testCases {
suite.Run(tc.name, func() {
s.Run(tc.name, func() {
logger := logr.Discard()

asConfig, err := NewMapAsConfig(logger, tc.version, tc.inputMap)
actual := asConfig.ToMap()

suite.Assert().Nil(err)
suite.Assert().Equal(tc.expected, *actual)
s.Assert().Nil(err)
s.Assert().Equal(tc.expected, *actual)
})
}
}
Expand Down
7 changes: 6 additions & 1 deletion asconfig/conffilewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import (
lib "github.com/aerospike/aerospike-management-lib"
)

const (
constLoggingConsole = "console"
constLoggingSyslog = "syslog"
)

func indentString(indent int) string {
return strings.Repeat(" ", indent*4)
}
Expand Down Expand Up @@ -86,7 +91,7 @@ func writeLogSection(
}

key := name
if name != "console" && name != "syslog" {
if name != constLoggingConsole && name != constLoggingSyslog {
key = "file " + name
}

Expand Down
Loading

0 comments on commit ed5cd65

Please sign in to comment.