Skip to content

Commit 0abd562

Browse files
committed
Fix formatting and removed nolint statement from tests
Signed-off-by: Raunak Madan <[email protected]>
1 parent 38462a1 commit 0abd562

File tree

3 files changed

+96
-108
lines changed

3 files changed

+96
-108
lines changed

integration-tests/meshsync_as_binary_with_k8s_cluster_integration_test.go

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ func TestMeshsyncBinaryWithK8sClusterIntegration(t *testing.T) {
5555
}
5656
}
5757

58-
// TODO fix cyclop error
59-
// integration-tests/k8s_cluster_integration_test.go:74:1: calculated cyclomatic complexity for function runWithMeshsyncBinaryAndk8sClusterMeshsyncBinaryTestCase is 11, max is 10 (cyclop)
60-
//
61-
//nolint:cyclop
6258
func runMeshsyncBinaryWithK8sClusterTestCase(
6359
br broker.Handler,
6460
tcIndex int,
@@ -107,7 +103,7 @@ func runMeshsyncBinaryWithK8sClusterTestCase(
107103
timeout = tc.waitMeshsyncTimeout
108104
}
109105

110-
waitForMeshsync(t, cmd, timeout)
106+
waitForMeshsync(t, cmd, timeout)
111107

112108
// Step 4: do final assertion, if any
113109
if tc.finalHandler != nil {
@@ -151,28 +147,26 @@ func withMeshsyncBinaryPrepareMeshsyncCMD(
151147
}
152148

153149
func waitForMeshsync(
154-
t *testing.T,
155-
cmd *exec.Cmd,
156-
timeout time.Duration,
150+
t *testing.T,
151+
cmd *exec.Cmd,
152+
timeout time.Duration,
157153
) {
158-
errCh := make(chan error)
159-
160-
go func(cmd0 *exec.Cmd, errCh0 chan<- error) {
161-
errCh0 <- cmd0.Wait()
162-
}(cmd, errCh)
163-
164-
select {
165-
case err := <-errCh:
166-
if err != nil {
167-
t.Fatalf("error running binary: %v", err)
168-
}
169-
case <-time.After(timeout):
170-
if err := cmd.Process.Signal(syscall.SIGTERM); err != nil {
171-
t.Fatalf("error terminating meshsync command: %v", err)
172-
}
173-
t.Logf("processing after timeout %d", timeout)
154+
errCh := make(chan error)
174155

175-
}
176-
}
156+
go func() {
157+
errCh <- cmd.Wait()
158+
}()
177159

160+
select {
161+
case err := <-errCh:
162+
if err != nil {
163+
t.Fatalf("error running binary: %v", err)
164+
}
165+
case <-time.After(timeout):
166+
if err := cmd.Process.Signal(syscall.SIGTERM); err != nil {
167+
t.Fatalf("error terminating meshsync command: %v", err)
168+
}
169+
t.Logf("processing after timeout %d", timeout)
178170

171+
}
172+
}

integration-tests/meshsync_as_library_with_k8s_cluster_custom_broker_integration_test.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ func TestMeshsyncLibraryWithK8sClusterCustomBrokerIntegration(t *testing.T) {
3535
}
3636
}
3737

38-
// TODO fix cyclop error
39-
// integration-tests/k8s_cluster_meshsync_as_library_integration_test.go:47:1: calculated cyclomatic complexity for function runWithMeshsyncLibraryAndk8sClusterTestCase is 15, max is 10 (cyclop)
40-
//
41-
//nolint:cyclop
4238
func runWithMeshsyncLibraryAndk8sClusterCustomBrokerTestCase(
4339
br broker.Handler,
4440
tcIndex int,
@@ -87,15 +83,15 @@ func runWithMeshsyncLibraryAndk8sClusterCustomBrokerTestCase(
8783

8884
// Step 3: run meshsync library
8985
runMeshsyncLibraryAsync(br, log, tc, errCh)
90-
86+
9187
// intentionally big timeout to wait till the run execution ended
9288
timeout := time.Duration(time.Hour * 24)
9389
if tc.waitMeshsyncTimeout > 0 {
9490
timeout = tc.waitMeshsyncTimeout
9591
}
9692

9793
handleLibraryCompletion(t, errCh, timeout, tc)
98-
94+
9995
// Step 4: do final assertion, if any
10096
if tc.finalHandler != nil {
10197
tc.finalHandler(t, resultData)
@@ -143,11 +139,11 @@ func runMeshsyncLibraryAsync(
143139
errCh chan<- error,
144140
) {
145141
go func() {
146-
runOptions := make([]libmeshsync.OptionsSetter, 0, len(tc.meshsyncRunOptions))
147-
runOptions = append(runOptions, tc.meshsyncRunOptions...)
148-
runOptions = append(runOptions, libmeshsync.WithBrokerHandler(br))
142+
runOptions := make([]libmeshsync.OptionsSetter, 0, len(tc.meshsyncRunOptions)+1)
143+
runOptions = append(runOptions, tc.meshsyncRunOptions...)
144+
runOptions = append(runOptions, libmeshsync.WithBrokerHandler(br))
149145

150-
errCh <- libmeshsync.Run(log, runOptions...)
146+
errCh <- libmeshsync.Run(log, runOptions...)
151147
}()
152148
}
153149

@@ -193,5 +189,3 @@ func validateErrorOutcome(
193189
t.Fatalf("must end with error")
194190
}
195191
}
196-
197-

0 commit comments

Comments
 (0)