internal/credential: simplify TestObject test helper (#3899)
The TestObject test helper previously returned an error, but it's easier to have it perform the error check itself, as it conventionally done with test helpers.
This commit is contained in:
1 parent
f9dee55e4d
commit
6081b6c58d
7 files changed
+18
-30
No files matched your search
@@ -108,8 +108,7 @@ func TestList(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
obj, objBytes, err := static.TestJsonObject()
|
||||
assert.NoError(t, err)
|
||||
obj, objBytes := static.TestJsonObject(t)
|
||||
|
||||
credJson := static.TestJsonCredential(t, conn, wrapper, store.GetPublicId(), prj.GetPublicId(), obj)
|
||||
hm, err = crypto.HmacSha256(ctx, objBytes, databaseWrapper, []byte(store.GetPublicId()), nil)
|
||||
@@ -244,7 +243,7 @@ func TestGet(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
passHm, err := crypto.HmacSha256(context.Background(), []byte(testdata.PEMEncryptedKeys[0].EncryptionKey), databaseWrapper, []byte(store.GetPublicId()), nil)
|
||||
|
||||
obj, objBytes, err := static.TestJsonObject()
|
||||
obj, objBytes := static.TestJsonObject(t)
|
||||
assert.NoError(t, err)
|
||||
|
||||
jsonCred := static.TestJsonCredential(t, conn, wrapper, store.GetPublicId(), prj.GetPublicId(), obj)
|
||||
@@ -428,7 +427,7 @@ func TestDelete(t *testing.T) {
|
||||
upCred := static.TestUsernamePasswordCredential(t, conn, wrapper, "user", "pass", store.GetPublicId(), prj.GetPublicId())
|
||||
spkCred := static.TestSshPrivateKeyCredential(t, conn, wrapper, "user", static.TestSshPrivateKeyPem, store.GetPublicId(), prj.GetPublicId())
|
||||
|
||||
obj, _, err := static.TestJsonObject()
|
||||
obj, _ := static.TestJsonObject(t)
|
||||
assert.NoError(t, err)
|
||||
|
||||
jsonCred := static.TestJsonCredential(t, conn, wrapper, store.GetPublicId(), prj.GetPublicId(), obj)
|
||||
@@ -497,8 +496,7 @@ func TestCreate(t *testing.T) {
|
||||
_, prj := iam.TestScopes(t, iamRepo)
|
||||
store := static.TestCredentialStore(t, conn, wrapper, prj.GetPublicId())
|
||||
|
||||
obj, objBytes, err := static.TestJsonObject()
|
||||
assert.NoError(t, err)
|
||||
obj, objBytes := static.TestJsonObject(t)
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
@@ -894,8 +892,7 @@ func TestUpdate(t *testing.T) {
|
||||
|
||||
freshCredJson := func() (*static.JsonCredential, func()) {
|
||||
t.Helper()
|
||||
obj, _, err := static.TestJsonObject()
|
||||
assert.NoError(t, err)
|
||||
obj, _ := static.TestJsonObject(t)
|
||||
cred := static.TestJsonCredential(t, conn, wrapper, store.GetPublicId(), prj.GetPublicId(), obj)
|
||||
clean := func() {
|
||||
_, err := s.DeleteCredential(ctx, &pbs.DeleteCredentialRequest{Id: cred.GetPublicId()})
|
||||
|
||||
Reference in new issue
Block a user