2022-05-24 15:08:02 -07:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-02-02 17:15:17 -08:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2022-05-24 15:08:02 -07:00
|
|
|
package targets
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
2022-06-20 18:20:17 -07:00
|
|
|
"github.com/hashicorp/boundary/internal/server"
|
2022-05-24 15:08:02 -07:00
|
|
|
"github.com/hashicorp/boundary/internal/types/scope"
|
|
|
|
|
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/targets"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestWorkerList_Addresses(t *testing.T) {
|
|
|
|
|
addresses := []string{
|
|
|
|
|
"test1",
|
|
|
|
|
"test2",
|
|
|
|
|
"test3",
|
|
|
|
|
"test4",
|
|
|
|
|
}
|
|
|
|
|
var workerInfos []*pb.WorkerInfo
|
2024-07-03 09:35:19 -07:00
|
|
|
var tested server.WorkerList
|
2022-05-24 15:08:02 -07:00
|
|
|
for _, a := range addresses {
|
|
|
|
|
workerInfos = append(workerInfos, &pb.WorkerInfo{Address: a})
|
2022-06-20 18:20:17 -07:00
|
|
|
tested = append(tested, server.NewWorker(scope.Global.String(),
|
|
|
|
|
server.WithName(a),
|
|
|
|
|
server.WithAddress(a)))
|
2022-05-24 15:08:02 -07:00
|
|
|
}
|
2023-01-04 11:24:09 -05:00
|
|
|
assert.Equal(t, addresses, tested.Addresses())
|
|
|
|
|
assert.Equal(t, workerInfos, tested.WorkerInfos())
|
2022-05-24 15:08:02 -07:00
|
|
|
}
|