mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
47 lines
910 B
Go
47 lines
910 B
Go
package cache
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
"sync"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/pomerium/pomerium/config"
|
|
"github.com/pomerium/pomerium/pkg/cryptutil"
|
|
)
|
|
|
|
func TestCache_runMemberList(t *testing.T) {
|
|
c, err := New(config.Options{
|
|
SharedKey: cryptutil.NewBase64Key(),
|
|
DataBrokerURL: &url.URL{Scheme: "http", Host: "member1"},
|
|
Provider: "google",
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
ctx, cancelFunc := context.WithTimeout(context.Background(), 1*time.Second)
|
|
defer cancelFunc()
|
|
|
|
ch := make(chan error)
|
|
var wg sync.WaitGroup
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
ch <- c.runMemberList(ctx)
|
|
close(ch)
|
|
}()
|
|
|
|
select {
|
|
case <-ctx.Done():
|
|
// No error
|
|
case err := <-ch:
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
// When we're here, either there an error, or ch was closed already.
|
|
assert.NoError(t, <-ch)
|
|
wg.Wait()
|
|
}
|