Skip to content

Commit e0d51a1

Browse files
committed
add more sdk tests
1 parent 115e3ae commit e0d51a1

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

internal/fleet/agent_policy/resource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestAccResourceAgentPolicyFromSDK(t *testing.T) {
3030
ExternalProviders: map[string]resource.ExternalProvider{
3131
"elasticstack": {
3232
Source: "elastic/elasticstack",
33-
VersionConstraint: "0.11.7", // Last provider version using the SDK
33+
VersionConstraint: "0.11.7",
3434
},
3535
},
3636
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionAgentPolicy),

internal/fleet/integration/resource_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,37 @@ import (
1212

1313
var minVersionIntegration = version.Must(version.NewVersion("8.6.0"))
1414

15+
func TestAccResourceIntegrationFromSDK(t *testing.T) {
16+
resource.Test(t, resource.TestCase{
17+
PreCheck: func() { acctest.PreCheck(t) },
18+
Steps: []resource.TestStep{
19+
{
20+
ExternalProviders: map[string]resource.ExternalProvider{
21+
"elasticstack": {
22+
Source: "elastic/elasticstack",
23+
VersionConstraint: "0.11.7",
24+
},
25+
},
26+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionIntegration),
27+
Config: testAccResourceIntegration,
28+
Check: resource.ComposeTestCheckFunc(
29+
resource.TestCheckResourceAttr("elasticstack_fleet_integration.test_integration", "name", "tcp"),
30+
resource.TestCheckResourceAttr("elasticstack_fleet_integration.test_integration", "version", "1.16.0"),
31+
),
32+
},
33+
{
34+
ProtoV6ProviderFactories: acctest.Providers,
35+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionIntegration),
36+
Config: testAccResourceIntegration,
37+
Check: resource.ComposeTestCheckFunc(
38+
resource.TestCheckResourceAttr("elasticstack_fleet_integration.test_integration", "name", "tcp"),
39+
resource.TestCheckResourceAttr("elasticstack_fleet_integration.test_integration", "version", "1.16.0"),
40+
),
41+
},
42+
},
43+
})
44+
}
45+
1546
func TestAccResourceIntegration(t *testing.T) {
1647
resource.Test(t, resource.TestCase{
1748
PreCheck: func() { acctest.PreCheck(t) },

internal/fleet/server_host/resource_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,45 @@ import (
1818

1919
var minVersionFleetServerHost = version.Must(version.NewVersion("8.6.0"))
2020

21+
func TestAccResourceFleetServerHostFromSDK(t *testing.T) {
22+
policyName := sdkacctest.RandString(22)
23+
24+
resource.Test(t, resource.TestCase{
25+
PreCheck: func() { acctest.PreCheck(t) },
26+
CheckDestroy: checkResourceFleetServerHostDestroy,
27+
Steps: []resource.TestStep{
28+
{
29+
ExternalProviders: map[string]resource.ExternalProvider{
30+
"elasticstack": {
31+
Source: "elastic/elasticstack",
32+
VersionConstraint: "0.11.7",
33+
},
34+
},
35+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionFleetServerHost),
36+
Config: testAccResourceFleetServerHostCreate(policyName),
37+
38+
Check: resource.ComposeTestCheckFunc(
39+
resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "name", fmt.Sprintf("FleetServerHost %s", policyName)),
40+
resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "id", "fleet-server-host-id"),
41+
resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "default", "false"),
42+
resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "hosts.0", "https://fleet-server:8220"),
43+
),
44+
},
45+
{
46+
ProtoV6ProviderFactories: acctest.Providers,
47+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionFleetServerHost),
48+
Config: testAccResourceFleetServerHostCreate(policyName),
49+
Check: resource.ComposeTestCheckFunc(
50+
resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "name", fmt.Sprintf("FleetServerHost %s", policyName)),
51+
resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "id", "fleet-server-host-id"),
52+
resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "default", "false"),
53+
resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "hosts.0", "https://fleet-server:8220"),
54+
),
55+
},
56+
},
57+
})
58+
}
59+
2160
func TestAccResourceFleetServerHost(t *testing.T) {
2261
policyName := sdkacctest.RandString(22)
2362

0 commit comments

Comments
 (0)