mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-10 23:03:23 +02:00
inmemory: add a test for the ListTypes race fix (#5327)
Add a test that interleaves calls to Put() (with different type strings)
and ListTypes(). At least on my machine, this appears to reliably detect
the data race fixed in commit 2f8743522d
when run with the Go race detector. (The 'make test' and 'make cover'
targets run with the Go race detector enabled.)
This commit is contained in:
parent
11054a943d
commit
298a5a94a5
1 changed files with 14 additions and 0 deletions
|
@ -252,3 +252,17 @@ func TestLease(t *testing.T) {
|
|||
assert.True(t, ok, "expected b to to acquire the lease")
|
||||
}
|
||||
}
|
||||
|
||||
// Concurrent calls to Put() and ListTypes() should not cause a data race.
|
||||
func TestListTypes_concurrent(_ *testing.T) {
|
||||
ctx := context.Background()
|
||||
backend := New()
|
||||
for i := 0; i < 10; i++ {
|
||||
t := fmt.Sprintf("Type-%02d", i)
|
||||
go backend.Put(ctx, []*databroker.Record{{
|
||||
Id: "1",
|
||||
Type: t,
|
||||
}})
|
||||
go backend.ListTypes(ctx)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue