certificate: close authDB in tests (#3559)

This commit is contained in:
Bryan White 2019-11-13 16:32:44 +01:00 committed by Michal Niewrzal
parent 1a9757a7f2
commit 0ff1547d08
4 changed files with 18 additions and 9 deletions

View File

@ -25,7 +25,10 @@ func TestEndpoint_Run_httpSuccess(t *testing.T) {
require.NotNil(t, listener)
log := zaptest.NewLogger(t)
service := NewService(log, newTestAuthDB(t, ctx))
authDB := newTestAuthDB(t, ctx)
defer ctx.Check(authDB.Close)
service := NewService(log, authDB)
endpoint := NewEndpoint(log, service, listener)
require.NotNil(t, endpoint)
@ -68,7 +71,10 @@ func TestEndpoint_Run_httpErrors(t *testing.T) {
require.NotNil(t, listener)
log := zaptest.NewLogger(t)
service := NewService(log, newTestAuthDB(t, ctx))
authDB := newTestAuthDB(t, ctx)
defer ctx.Check(authDB.Close)
service := NewService(log, authDB)
endpoint := NewEndpoint(log, service, listener)
require.NotNil(t, endpoint)

View File

@ -4,7 +4,6 @@
package authorization
import (
"net"
"testing"
"github.com/stretchr/testify/require"
@ -19,6 +18,8 @@ func TestService_GetOrCreate(t *testing.T) {
defer ctx.Cleanup()
authorizationDB := newTestAuthDB(t, ctx)
defer ctx.Check(authorizationDB.Close)
service := NewService(zaptest.NewLogger(t), authorizationDB)
require.NotNil(t, service)
@ -57,11 +58,9 @@ func TestService_GetOrCreate_error(t *testing.T) {
ctx := testcontext.New(t)
defer ctx.Cleanup()
listener, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
require.NotNil(t, listener)
authorizationDB := newTestAuthDB(t, ctx)
defer ctx.Check(authorizationDB.Close)
service := NewService(zaptest.NewLogger(t), authorizationDB)
require.NotNil(t, service)

View File

@ -62,7 +62,8 @@ func TestCertificateSigner_Sign_E2E(t *testing.T) {
certificatesCfg := certificate.Config{
Signer: signerCAConfig,
Server: server.Config{
Address: "127.0.0.1:0",
Address: "127.0.0.1:0",
PrivateAddress: "127.0.0.1:0",
Config: tlsopts.Config{
PeerIDVersions: "*",
},

View File

@ -78,6 +78,7 @@ func TestPeer_Run(t *testing.T) {
t.Run("random rollouts", func(t *testing.T) {
for i := 0; i < 100; i++ {
config := versioncontrol.Config{
Address: "127.0.0.1:0",
Versions: testServiceVersions,
Binary: validRandVersions(t),
}
@ -108,6 +109,7 @@ func TestPeer_Run(t *testing.T) {
field.Set(reflect.ValueOf(binary))
config := versioncontrol.Config{
Address: "127.0.0.1:0",
Versions: testServiceVersions,
Binary: versions,
}
@ -139,7 +141,8 @@ func TestPeer_Run_error(t *testing.T) {
field.Set(reflect.ValueOf(binary))
config := versioncontrol.Config{
Binary: versions,
Address: "127.0.0.1:0",
Binary: versions,
}
peer, err := versioncontrol.New(zaptest.NewLogger(t), &config)