Skip to content

Commit 701c9ad

Browse files
committed
chore: improve code readability
1 parent ce8aa66 commit 701c9ad

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

cli/sharing_test.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cli_test
33
import (
44
"bytes"
55
"fmt"
6+
"slices"
67
"strings"
78
"testing"
89

@@ -114,19 +115,15 @@ func TestSharingShare(t *testing.T) {
114115
Role: codersdk.WorkspaceRoleUse,
115116
})
116117

117-
// Test that the users appeart in the output
118+
// Test that the users appear in the output
118119
outputLines := strings.Split(out.String(), "\n")
119120
userNames := []string{toShareWithUser1.Username, toShareWithUser2.Username}
120121
for _, username := range userNames {
121-
found := false
122-
for _, line := range outputLines {
123-
if strings.Contains(line, username) {
124-
found = true
125-
break
126-
}
127-
}
122+
index := slices.IndexFunc(outputLines, func(line string) bool {
123+
return strings.Contains(line, username)
124+
})
128125

129-
assert.True(t, found, fmt.Sprintf("Expected to find the username %s in the command output: %s", username, out.String()))
126+
assert.True(t, index != -1, fmt.Sprintf("Expected to find the username %s in the command output: %s", username, out.String()))
130127
}
131128
})
132129

0 commit comments

Comments
 (0)