forked from ovh/terraform-provider-ovh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_cloud_project_database_log_subscription_test.go
113 lines (103 loc) · 3.13 KB
/
data_cloud_project_database_log_subscription_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package ovh
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
const testAccCloudProjectDatabaseLogSubsriptionDatasourceConfig_Basic = `
resource "ovh_cloud_project_database" "db" {
service_name = "%s"
description = "%s"
engine = "%s"
version = "%s"
plan = "essential"
nodes {
region = "%s"
}
flavor = "%s"
}
resource "ovh_dbaas_logs_output_graylog_stream" "stream" {
service_name = "%s"
title = "%s"
description = "%s"
}
resource "ovh_cloud_project_database_log_subscription" "sub" {
service_name = ovh_cloud_project_database.db.service_name
engine = ovh_cloud_project_database.db.engine
cluster_id = ovh_cloud_project_database.db.id
stream_id = ovh_dbaas_logs_output_graylog_stream.stream.id
}
data "ovh_cloud_project_database_log_subscription" "sub" {
service_name = ovh_cloud_project_database_log_subscription.sub.service_name
engine = ovh_cloud_project_database_log_subscription.sub.engine
cluster_id = ovh_cloud_project_database_log_subscription.sub.cluster_id
id = ovh_cloud_project_database_log_subscription.sub.id
}
`
func TestAccCloudProjectDatabaseLogSubscriptionDataSource_basic(t *testing.T) {
serviceName := os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST")
engine := os.Getenv("OVH_CLOUD_PROJECT_DATABASE_ENGINE_TEST")
version := os.Getenv("OVH_CLOUD_PROJECT_DATABASE_VERSION_TEST")
region := os.Getenv("OVH_CLOUD_PROJECT_DATABASE_REGION_TEST")
flavor := os.Getenv("OVH_CLOUD_PROJECT_DATABASE_FLAVOR_TEST")
description := acctest.RandomWithPrefix(test_prefix)
LDPserviceName := os.Getenv("OVH_DBAAS_LOGS_SERVICE_TEST")
title := acctest.RandomWithPrefix(test_prefix)
desc := acctest.RandomWithPrefix(test_prefix)
config := fmt.Sprintf(
testAccCloudProjectDatabaseLogSubsriptionDatasourceConfig_Basic,
serviceName,
description,
engine,
version,
region,
flavor,
LDPserviceName,
title,
desc,
)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckDbaasLogs(t)
testAccPreCheckCloudDatabaseNoEngine(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(
"ovh_cloud_project_database_log_subscription.sub",
"created_at",
),
resource.TestCheckResourceAttrSet(
"ovh_cloud_project_database_log_subscription.sub",
"kind",
),
resource.TestCheckResourceAttrSet(
"ovh_cloud_project_database_log_subscription.sub",
"ldp_service_name",
),
resource.TestCheckResourceAttrSet(
"ovh_cloud_project_database_log_subscription.sub",
"resource_name",
),
resource.TestCheckResourceAttrSet(
"ovh_cloud_project_database_log_subscription.sub",
"resource_type",
),
resource.TestCheckResourceAttrSet(
"ovh_cloud_project_database_log_subscription.sub",
"stream_id",
),
resource.TestCheckResourceAttrSet(
"ovh_cloud_project_database_log_subscription.sub",
"updated_at",
),
),
},
},
})
}