Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yoanm committed Mar 27, 2024
1 parent 4d0a2e6 commit 8153ff5
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 368 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ linters:
- revive # see disabled linters below
- unused # see disabled linters below
disable:
- depguard # Should not be enabled by default but seems anyway .....
- structcheck # deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
- ifshort # deprecated (since v1.48.0) due to: The repository of the linter has been deprecated by the owner.
- interfacer # deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ help: ## ❓ Dislay this help
.PHONY: configure-dev-env
configure-dev-env: ## 🤖 Install required libraries for dev environment
configure-dev-env:
go install github.com/posener/goreadme/cmd/goreadme@latest
go install github.com/posener/goreadme/cmd/goreadme@v1
.PHONY: configure-test-env
configure-test-env: ## 🤖 Install required libraries for test environment (golint, staticcheck, etc)
configure-test-env: configure-dev-env
configure-test-env:
# Nothing to install currently
go install github.com/golangci/golangci-lint/cmd/[email protected]

##—— 📝 Documentation —————————————————————————————————————————————————
.PHONY: build-doc
Expand All @@ -60,7 +60,7 @@ build: ## 🗜️ Build package
#### Use build_o="..." to specify build options
$(eval build_o ?=)
build:
go build -v $(build_o)
go build -v -o github-tf $(build_o)

.PHONY: verify-deps
verify-deps: ## 🗜️ Verify dependencies
Expand Down
10 changes: 4 additions & 6 deletions core/config_computer_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package core_test

import (
"fmt"
"errors"
"testing"

differ "github.com/andreyvit/diff"
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestComputeConfig(t *testing.T) {
},
},
nil,
fmt.Errorf("error during computation:\n\t - repo #0: repository name is mandatory\n\t - repo #1: repository name is mandatory"),
errors.New("error during computation:\n\t - repo #0: repository name is mandatory\n\t - repo #1: repository name is mandatory"),
},
"Underlying computation error": {
&core.Config{
Expand All @@ -82,18 +82,16 @@ func TestComputeConfig(t *testing.T) {
},
},
nil,
fmt.Errorf("error during computation:\n\t - repository a_name: repository template not found as none available"),
errors.New("error during computation:\n\t - repository a_name: repository template not found as none available"),
},
}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel tests
tc := tc // Reinit var for parallel tests

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual, err := core.ComputeConfig(tc.value)
if tc.error != nil {
if err == nil {
Expand Down
16 changes: 4 additions & 12 deletions core/config_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ func TestConfig_GetRepo(t *testing.T) {
}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel tests
tc := tc // Reinit var for parallel tests

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := tc.value.GetRepo(tc.name)
if diff := cmp.Diff(tc.expected, actual); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -79,13 +77,11 @@ func TestTemplatesConfig_GetRepo(t *testing.T) {
}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel tests
tc := tc // Reinit var for parallel tests

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := tc.value.GetRepo(tc.name)
if diff := cmp.Diff(tc.expected, actual); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -123,13 +119,11 @@ func TestTemplatesConfig_GetBranch(t *testing.T) {
}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel tests
tc := tc // Reinit var for parallel tests

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := tc.value.GetBranch(tc.name)
if diff := cmp.Diff(tc.expected, actual); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -167,13 +161,11 @@ func TestTemplatesConfig_GetBranchProtection(t *testing.T) {
}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel tests
tc := tc // Reinit var for parallel tests

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := tc.value.GetBranchProtection(tc.name)
if diff := cmp.Diff(tc.expected, actual); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down
25 changes: 7 additions & 18 deletions core/gh2tf_repo_mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,11 @@ func TestMapToRepositoryRes(t *testing.T) {
diffOpts := []cmp.Option{cmp.AllowUnexported(tfsig.ValueGenerator{}), cmp.AllowUnexported(tfsig.IdentTokenMatcher{})}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel test
tc := tc // Reinit var for parallel test

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := core.MapToRepositoryRes(tc.value, valGen, tfRepoId)
if diff := cmp.Diff(tc.expected, actual, diffOpts...); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -176,13 +174,11 @@ func TestMapToBranchRes(t *testing.T) {
diffOpts := []cmp.Option{cmp.AllowUnexported(tfsig.ValueGenerator{}), cmp.AllowUnexported(tfsig.IdentTokenMatcher{})}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel test
tc := tc // Reinit var for parallel test

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := core.MapToBranchRes(tc.name, tc.value, valGen, tc.repo, tfId, tc.links...)
if diff := cmp.Diff(tc.expected, actual, diffOpts...); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -270,13 +266,11 @@ func TestMapToDefaultBranchRes(t *testing.T) {
diffOpts := []cmp.Option{cmp.AllowUnexported(tfsig.ValueGenerator{}), cmp.AllowUnexported(tfsig.IdentTokenMatcher{})}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel test
tc := tc // Reinit var for parallel test

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := core.MapToDefaultBranchRes(tc.value, valGen, tc.repo, tfId, tc.links...)
if diff := cmp.Diff(tc.expected, actual, diffOpts...); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -380,13 +374,11 @@ func TestMapDefaultBranchToBranchProtectionRes(t *testing.T) {
diffOpts := []cmp.Option{cmp.AllowUnexported(tfsig.ValueGenerator{}), cmp.AllowUnexported(tfsig.IdentTokenMatcher{})}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel test
tc := tc // Reinit var for parallel test

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := core.MapDefaultBranchToBranchProtectionRes(tc.value, valGen, tc.repo, tfId, tc.links...)
if diff := cmp.Diff(tc.expected, actual, diffOpts...); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -475,15 +467,14 @@ func TestMapBranchToBranchProtectionRes(t *testing.T) {
diffOpts := []cmp.Option{cmp.AllowUnexported(tfsig.ValueGenerator{}), cmp.AllowUnexported(tfsig.IdentTokenMatcher{})}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel test
tc := tc // Reinit var for parallel test

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

branchNameTmp := tc.name
actual := core.MapBranchToBranchProtectionRes(&branchNameTmp, tc.value, valGen, tc.repo, tfId, tc.links...)

if diff := cmp.Diff(tc.expected, actual, diffOpts...); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
}
Expand Down Expand Up @@ -575,13 +566,11 @@ func TestMapToBranchProtectionRes(t *testing.T) {
diffOpts := []cmp.Option{cmp.AllowUnexported(tfsig.ValueGenerator{}), cmp.AllowUnexported(tfsig.IdentTokenMatcher{})}

for tcname, tc := range cases {
tcname := tcname // Reinit var for parallel test
tc := tc // Reinit var for parallel test

t.Run(
tcname,
func(t *testing.T) {
t.Parallel()

actual := core.MapToBranchProtectionRes(tc.value, valGen, tc.repo, tfId, tc.links...)
if diff := cmp.Diff(tc.expected, actual, diffOpts...); diff != "" {
t.Errorf("Config mismatch (-want +got):\n%s", diff)
Expand Down
Loading

0 comments on commit 8153ff5

Please sign in to comment.