mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-15 18:17:49 +02:00
postgres: databroker storage backend (#3370)
* wip * storage: add filtering to SyncLatest * don't increment the record version, so intermediate changes are requested * databroker: add support for query filtering * fill server and record version * postgres: databroker storage backend * wip * serialize puts * add test * skip tests for macos * add test * return error from protojson * set data * exclude postgres from cover tests
This commit is contained in:
parent
550698b1ca
commit
1c2aad2de6
21 changed files with 1573 additions and 17 deletions
34
pkg/contextutil/contextutil_test.go
Normal file
34
pkg/contextutil/contextutil_test.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package contextutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMerge(t *testing.T) {
|
||||
t.Run("value", func(t *testing.T) {
|
||||
ctx1 := context.WithValue(context.Background(), "key1", "value1") //nolint
|
||||
ctx2 := context.WithValue(context.Background(), "key2", "value2") //nolint
|
||||
ctx3, _ := Merge(ctx1, ctx2)
|
||||
assert.Equal(t, "value1", ctx3.Value("key1"))
|
||||
assert.Equal(t, "value2", ctx3.Value("key2"))
|
||||
})
|
||||
t.Run("cancel", func(t *testing.T) {
|
||||
ctx1, cancel1 := context.WithCancel(context.Background())
|
||||
defer cancel1()
|
||||
ctx2, cancel2 := context.WithCancel(context.Background())
|
||||
ctx3, _ := Merge(ctx1, ctx2)
|
||||
cancel2()
|
||||
assert.Eventually(t, func() bool {
|
||||
select {
|
||||
case <-ctx3.Done():
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}, time.Second, time.Millisecond*100)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue