Skip to content

Commit 817e00c

Browse files
Merge pull request #223 from codecrafters-io/pluralize
Pluralize in blocking client group test case
2 parents 4c6254e + 1bd7415 commit 817e00c

File tree

3 files changed

+137
-133
lines changed

3 files changed

+137
-133
lines changed

internal/test_cases/blocking_client_group_test_case.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ func (t *BlockingClientGroupTestCase) SendBlockingCommands() error {
3737
func (t *BlockingClientGroupTestCase) AssertResponses(logger *logger.Logger) error {
3838
// ensure that exactly 'ResponseExpectingClientsCount' clients receive the response
3939
// if the count is less -> error, more -> error
40-
clientWord := "client"
41-
if t.ResponseExpectingClientsCount != 1 {
42-
clientWord = "clients"
43-
}
44-
logger.Infof("Expecting %d %s to receive response of %s command", t.ResponseExpectingClientsCount, clientWord, t.CommandToSend[0])
40+
logger.Infof(
41+
"Expecting %d %s to receive response of %s command",
42+
t.ResponseExpectingClientsCount,
43+
pluralize(t.ResponseExpectingClientsCount, "client", "clients"),
44+
t.CommandToSend[0],
45+
)
4546

4647
receivedResponsesCount := 0
4748

internal/test_cases/utils.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package test_cases
2+
3+
func pluralize(n int, singular, plural string) string {
4+
if n == 1 {
5+
return singular
6+
}
7+
return plural
8+
}

0 commit comments

Comments
 (0)