2023-08-11 09:12:13 -04:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
2023-06-06 17:09:48 -04:00
|
|
|
package catalogtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/internal/catalog"
|
2024-01-12 11:54:07 -05:00
|
|
|
"github.com/hashicorp/consul/internal/controller/controllertest"
|
2024-02-07 13:35:02 -05:00
|
|
|
"github.com/hashicorp/consul/internal/multicluster"
|
2023-06-06 17:09:48 -04:00
|
|
|
"github.com/hashicorp/consul/internal/resource/reaper"
|
2023-11-08 10:45:25 -05:00
|
|
|
rtest "github.com/hashicorp/consul/internal/resource/resourcetest"
|
2023-06-06 17:09:48 -04:00
|
|
|
"github.com/hashicorp/consul/proto-public/pbresource"
|
|
|
|
)
|
|
|
|
|
2023-11-08 10:45:25 -05:00
|
|
|
var (
|
|
|
|
clientOpts = rtest.ConfigureTestCLIFlags()
|
|
|
|
)
|
|
|
|
|
2024-01-19 09:35:34 -05:00
|
|
|
func runInMemResourceServiceAndControllers(t *testing.T) pbresource.ResourceServiceClient {
|
2023-06-06 17:09:48 -04:00
|
|
|
t.Helper()
|
|
|
|
|
2024-01-12 11:54:07 -05:00
|
|
|
return controllertest.NewControllerTestBuilder().
|
2024-02-07 13:35:02 -05:00
|
|
|
WithResourceRegisterFns(catalog.RegisterTypes, multicluster.RegisterTypes).
|
2024-01-12 11:54:07 -05:00
|
|
|
WithControllerRegisterFns(
|
|
|
|
reaper.RegisterControllers,
|
2024-01-19 09:35:34 -05:00
|
|
|
catalog.RegisterControllers,
|
2024-01-12 11:54:07 -05:00
|
|
|
).Run(t)
|
2023-06-06 17:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestControllers_Integration(t *testing.T) {
|
2024-01-19 09:35:34 -05:00
|
|
|
client := runInMemResourceServiceAndControllers(t)
|
2023-11-08 10:45:25 -05:00
|
|
|
RunCatalogV2Beta1IntegrationTest(t, client, clientOpts.ClientOptions(t)...)
|
2023-06-06 17:09:48 -04:00
|
|
|
}
|
2023-06-16 12:58:53 -04:00
|
|
|
|
|
|
|
func TestControllers_Lifecycle(t *testing.T) {
|
2024-01-19 09:35:34 -05:00
|
|
|
client := runInMemResourceServiceAndControllers(t)
|
2023-11-08 10:45:25 -05:00
|
|
|
RunCatalogV2Beta1LifecycleIntegrationTest(t, client, clientOpts.ClientOptions(t)...)
|
2023-06-16 12:58:53 -04:00
|
|
|
}
|