forked from TrueCloudLab/certificates
Add test.
This commit is contained in:
parent
120e2d0caf
commit
9f39cb5f2a
1 changed files with 24 additions and 0 deletions
|
@ -3,11 +3,13 @@ package authority
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/smallstep/assert"
|
"github.com/smallstep/assert"
|
||||||
"github.com/smallstep/certificates/authority/provisioner"
|
"github.com/smallstep/certificates/authority/provisioner"
|
||||||
|
"github.com/smallstep/certificates/db"
|
||||||
stepJOSE "github.com/smallstep/cli/jose"
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue