Skip to content

Commit

Permalink
Lint files with 'integration' build flag (#1508)
Browse files Browse the repository at this point in the history
'golangci-lint' has to be instructed to not skip code that has build tags. By adding 'integration' to the 'build-tags' property, we ensure that integration tests are linted.

Signed-off-by: Jan Schlicht <jan@d2iq.com>
  • Loading branch information
Jan Schlicht committed May 18, 2020
1 parent 87b7966 commit 98a90e6
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 80 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ linters:
- goconst
- lll
run:
build-tags:
- integration
skip-dirs:
# autogenerated clientset by client-gen
- pkg/client
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/instance/instance_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func TestRestartController(t *testing.T) {
}
instanceKey, _ := client.ObjectKeyFromObject(in)
assert.NoError(t, c.Create(context.TODO(), in))
defer c.Delete(context.TODO(), in)

ov := &v1beta1.OperatorVersion{
ObjectMeta: metav1.ObjectMeta{Name: "foo-operator", Namespace: "default"},
Expand All @@ -90,7 +89,6 @@ func TestRestartController(t *testing.T) {
},
}
assert.NoError(t, c.Create(context.TODO(), ov))
defer c.Delete(context.TODO(), ov)

log.Print("And a deploy plan that was already run")
assert.Eventually(t, func() bool { return instancePlanFinished(instanceKey, "deploy", c) }, timeout, tick)
Expand Down Expand Up @@ -140,6 +138,7 @@ func startTestManager(t *testing.T) (chan struct{}, *sync.WaitGroup, client.Clie
Recorder: mgr.GetEventRecorderFor("instance-controller"),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr)
assert.NoError(t, err, "Error when setting up manager")

stop := make(chan struct{})
wg := &sync.WaitGroup{}
Expand Down Expand Up @@ -326,6 +325,8 @@ func Test_makePipes(t *testing.T) {
}

for _, tt := range tests {
tt := tt

t.Run(tt.name, func(t *testing.T) {
got, err := PipesMap(tt.planName, tt.plan, tt.tasks, tt.emeta)
if err != nil {
Expand Down Expand Up @@ -553,6 +554,8 @@ func Test_fetchNewExecutionPlan(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt

t.Run(tt.name, func(t *testing.T) {
got, err := fetchNewExecutionPlan(tt.i, tt.ov)
assert.Equal(t, tt.wantErr, err != nil, "expected error %v, but got %v", tt.wantErr, err)
Expand Down
Loading

0 comments on commit 98a90e6

Please sign in to comment.