Files
threshold/internal/servers/testing_test.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1.0 KiB
Go
Raw Normal View History

2022-05-20 11:55:54 -07:00
package servers
import (
"context"
"strings"
"testing"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/types/scope"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestTestWorker(t *testing.T) {
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
2022-06-03 11:19:04 -07:00
const (
name = "test name"
description = "test description"
address = "test address"
)
tWorker := TestWorker(t, conn, wrapper, WithName(name), WithDescription(description), WithAddress(address))
2022-05-20 11:55:54 -07:00
assert.NotNil(t, tWorker)
assert.True(t, strings.HasPrefix(tWorker.GetPublicId(), WorkerPrefix))
lkpWorker := NewWorker(scope.Global.String())
lkpWorker.PublicId = tWorker.GetPublicId()
2022-05-20 11:55:54 -07:00
rw := db.New(conn)
require.NoError(t, rw.LookupById(context.Background(), lkpWorker))
assert.NotNil(t, lkpWorker)
2022-06-03 11:19:04 -07:00
assert.NotNil(t, lkpWorker.GetLastStatusTime())
assert.Equal(t, name, lkpWorker.GetName())
assert.Equal(t, description, lkpWorker.GetDescription())
assert.Equal(t, address, lkpWorker.GetAddress())
2022-05-20 11:55:54 -07:00
}