internal/databroker: handle new db error (#1129)

Since when we now support other storage, not only memory storage, we
need to handle the error when we can't connect to storage.
This commit is contained in:
Cuong Manh Le 2020-07-23 22:48:34 +07:00 committed by GitHub
parent 1640151bc1
commit 1867feb5b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 19 deletions

View file

@ -7,6 +7,7 @@ import (
"github.com/golang/protobuf/ptypes"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pomerium/pomerium/internal/log"
"github.com/pomerium/pomerium/pkg/grpc/databroker"
@ -37,7 +38,8 @@ func TestServer_initVersion(t *testing.T) {
t.Run("new server with random version", func(t *testing.T) {
srv := newServer(cfg)
ctx := context.Background()
db := srv.getDB(recordTypeServerVersion)
db, err := srv.getDB(recordTypeServerVersion)
require.NoError(t, err)
r := db.Get(ctx, serverVersionKey)
assert.Nil(t, r)
srvVersion := uuid.New().String()
@ -53,7 +55,8 @@ func TestServer_initVersion(t *testing.T) {
t.Run("init version twice should get the same version", func(t *testing.T) {
srv := newServer(cfg)
ctx := context.Background()
db := srv.getDB(recordTypeServerVersion)
db, err := srv.getDB(recordTypeServerVersion)
require.NoError(t, err)
r := db.Get(ctx, serverVersionKey)
assert.Nil(t, r)