From 9f39cb5f2abf683f59ecccebdd6c007d22e3f302 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Fri, 10 May 2019 16:53:35 -0700 Subject: [PATCH] Add test. --- authority/authority_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/authority/authority_test.go b/authority/authority_test.go index 8f180457..30ee3121 100644 --- a/authority/authority_test.go +++ b/authority/authority_test.go @@ -3,11 +3,13 @@ package authority import ( "crypto/sha256" "encoding/hex" + "reflect" "testing" "github.com/pkg/errors" "github.com/smallstep/assert" "github.com/smallstep/certificates/authority/provisioner" + "github.com/smallstep/certificates/db" stepJOSE "github.com/smallstep/cli/jose" ) @@ -139,3 +141,25 @@ func TestAuthorityNew(t *testing.T) { }) } } + +func TestAuthority_GetDatabase(t *testing.T) { + auth := testAuthority(t) + authWithDatabase, err := New(auth.config, WithDatabase(auth.db)) + assert.FatalError(t, err) + + tests := []struct { + name string + auth *Authority + want db.AuthDB + }{ + {"ok", auth, auth.db}, + {"ok WithDatabase", authWithDatabase, auth.db}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.auth.GetDatabase(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("Authority.GetDatabase() = %v, want %v", got, tt.want) + } + }) + } +}