You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
boundary/internal/alias/target/testing_test.go

39 lines
1.2 KiB

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package target_test
import (
"context"
"testing"
atar "github.com/hashicorp/boundary/internal/alias/target"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/target/tcp"
"github.com/stretchr/testify/assert"
)
func TestTestAlias(t *testing.T) {
conn, _ := db.TestSetup(t, "postgres")
rw := db.New(conn)
wrapper := db.TestWrapper(t)
iamRepo := iam.TestRepo(t, conn, wrapper)
_, proj := iam.TestScopes(t, iamRepo)
tar := tcp.TestTarget(context.Background(), t, conn, proj.GetPublicId(), "test target")
a := atar.TestAlias(t, rw, "example.alias",
atar.WithDescription("description"),
atar.WithName("name"),
atar.WithDestinationId(tar.GetPublicId()),
atar.WithHostId("hst_1234567890"))
assert.Equal(t, "example.alias", a.GetValue())
assert.Equal(t, "description", a.GetDescription())
assert.Equal(t, "name", a.GetName())
assert.Equal(t, tar.GetPublicId(), a.GetDestinationId())
assert.Equal(t, "hst_1234567890", a.GetHostId())
assert.Equal(t, "global", a.GetScopeId())
assert.NotEmpty(t, a.GetPublicId())
}