Skip to content

Commit

Permalink
Merge pull request #21 from EchoVault/chore/fix-race-condition
Browse files Browse the repository at this point in the history
Fixed race conditions in acl module tests
  • Loading branch information
kelvinmwinuka authored Apr 5, 2024
2 parents 9b7d93f + 64bbda6 commit c6b246e
Show file tree
Hide file tree
Showing 13 changed files with 4,118 additions and 3,338 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Test
run: go test -coverprofile=coverage.out -v ./...

- name: Test for Data Race
run: go test ./... --race

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ run:

test:
go clean -testcache && go test ./... -coverprofile coverage/coverage.out

test-race:
go clean -testcache && go test ./... --race
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
<br/>
[![Go Reference](https://pkg.go.dev/badge/github.com/echovault/echovault.svg)](https://pkg.go.dev/github.com/echovault/echovault)
<br/>
[![Discord](https://img.shields.io/discord/1211815152291414037?style=flat&label=Discord&color=%235865F2)
](https://discord.gg/aasBFwDm)
<br/>
<hr/>

<img alt="echovault_logo" src="./images/EchoVault GitHub Cover.png" width="5062" />
Expand Down
514 changes: 257 additions & 257 deletions coverage/coverage.out

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/clock/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (RealClock) After(d time.Duration) <-chan time.Time {
type MockClock struct{}

func (MockClock) Now() time.Time {
t, _ := time.Parse(time.RFC3339, "2036-01-02T15:04:05+07:00")
t, _ := time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00")
return t
}

Expand Down
13 changes: 6 additions & 7 deletions pkg/modules/acl/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var mockServer *echovault.EchoVault

func init() {
bindAddr = "localhost"
port = 7490
port = 7496

mockServer = setUpServer(bindAddr, port, true, "")

Expand Down Expand Up @@ -1019,7 +1019,7 @@ func Test_HandleSetUser(t *testing.T) {

for i, test := range tests {
if test.presetUser != nil {
acl.Users = append(acl.Users, test.presetUser)
acl.AddUsers([]*internal_acl.User{test.presetUser})
}
if err = r.WriteArray(test.cmd); err != nil {
t.Error(err)
Expand Down Expand Up @@ -1164,7 +1164,7 @@ func Test_HandleGetUser(t *testing.T) {

for _, test := range tests {
if test.presetUser != nil {
acl.Users = append(acl.Users, test.presetUser)
acl.AddUsers([]*internal_acl.User{test.presetUser})
}
if err = r.WriteArray(test.cmd); err != nil {
t.Error(err)
Expand Down Expand Up @@ -1261,7 +1261,7 @@ func Test_HandleDelUser(t *testing.T) {

for _, test := range tests {
if test.presetUser != nil {
acl.Users = append(acl.Users, test.presetUser)
acl.AddUsers([]*internal_acl.User{test.presetUser})
}
if err = r.WriteArray(test.cmd); err != nil {
t.Error(err)
Expand Down Expand Up @@ -1456,9 +1456,8 @@ func Test_HandleList(t *testing.T) {
}

for _, test := range tests {
for _, user := range test.presetUsers {
acl.Users = append(acl.Users, user)
}
acl.AddUsers(test.presetUsers)

if err = r.WriteArray(test.cmd); err != nil {
t.Error(err)
}
Expand Down
Loading

0 comments on commit c6b246e

Please sign in to comment.