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