This moves all of the tcp target functionality into a tcp package. It also establishes a Register function in the target package to allow specific target types to be registered at initilazation time. When registering, a target type needs to provide its Subtype, as well as some RepositoryHooks that are used by the target Repository.
23 lines
538 B
Go
23 lines
538 B
Go
package target
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestCredentialLibrary creates a CredentialLibrary for targetId and
|
|
// libraryId.
|
|
func TestCredentialLibrary(t *testing.T, conn *db.DB, targetId, libraryId string) *CredentialLibrary {
|
|
t.Helper()
|
|
require := require.New(t)
|
|
rw := db.New(conn)
|
|
lib, err := NewCredentialLibrary(targetId, libraryId)
|
|
require.NoError(err)
|
|
err = rw.Create(context.Background(), lib)
|
|
require.NoError(err)
|
|
return lib
|
|
}
|