From 1e322396e30f6d8a857e8517a0ff1bb7978814b5 Mon Sep 17 00:00:00 2001 From: Sherzod Karimov Date: Fri, 6 Oct 2023 15:08:37 -0400 Subject: [PATCH] add test --- ...cDatadogServiceDefinition_BasicV2_2.freeze | 1 + ...AccDatadogServiceDefinition_BasicV2_2.yaml | 104 ++++++++++++++++++ ...ce_datadog_service_definition_yaml_test.go | 19 ++++ 3 files changed, 124 insertions(+) create mode 100644 datadog/tests/cassettes/TestAccDatadogServiceDefinition_BasicV2_2.freeze create mode 100644 datadog/tests/cassettes/TestAccDatadogServiceDefinition_BasicV2_2.yaml diff --git a/datadog/tests/cassettes/TestAccDatadogServiceDefinition_BasicV2_2.freeze b/datadog/tests/cassettes/TestAccDatadogServiceDefinition_BasicV2_2.freeze new file mode 100644 index 0000000000..6b42c34895 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogServiceDefinition_BasicV2_2.freeze @@ -0,0 +1 @@ +2023-10-06T15:07:19.795264-04:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogServiceDefinition_BasicV2_2.yaml b/datadog/tests/cassettes/TestAccDatadogServiceDefinition_BasicV2_2.yaml new file mode 100644 index 0000000000..bbcec9cca2 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogServiceDefinition_BasicV2_2.yaml @@ -0,0 +1,104 @@ +--- +version: 1 +interactions: +- request: + body: "schema-version: v2.2\ndd-service: tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239\ncontacts:\n - contact: contact@datadoghq.com\n name: Team Email\n type: email\nextensions:\n myorgextension: extensionvalue\nintegrations:\n opsgenie:\n region: US\n service-url: https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\n pagerduty:\n service-url: https://my-org.pagerduty.com/service-directory/PMyService\nlinks:\n - name: Architecture\n type: doc\n provider: Gigoogle drivetHub\n url: https://my-runbook\n - name: Runbook\n type: runbook\n url: https://my-runbook\n - name: Source Code\n type: repo\n provider: GitHub\n url: https://github.com/DataDog/schema\ntags:\n - my:tag\n - service:tag\nteam: my-team \nlanguages:\n - go\n - python\nservice-type: web\n" + form: {} + headers: + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/services/definitions + method: POST + response: + body: | + {"data":[{"type":"service-definition","attributes":{"meta":{"last-modified-time":"2023-10-06T19:07:21.086499009Z","github-html-url":"","ingestion-source":"api","origin":"dd_terraform","origin-detail":"","warnings":[],"ingested-schema-version":"v2.2"},"schema":{"schema-version":"v2.2","dd-service":"tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239","team":"my-team","contacts":[{"name":"Team Email","type":"email","contact":"contact@datadoghq.com"}],"links":[{"name":"Architecture","type":"doc","provider":"Gigoogle drivetHub","url":"https://my-runbook"},{"name":"Runbook","type":"runbook","url":"https://my-runbook"},{"name":"Source Code","type":"repo","provider":"GitHub","url":"https://github.com/DataDog/schema"}],"tags":["my:tag","service:tag"],"integrations":{"pagerduty":{"service-url":"https://my-org.pagerduty.com/service-directory/PMyService"},"opsgenie":{"service-url":"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000","region":"US"}},"extensions":{"myorgextension":"extensionvalue"},"service-type":"web","languages":["go","python"]}}}]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/services/definitions/tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239 + method: GET + response: + body: | + {"errors":["Not Found"],"error_details":[{}]} + headers: + Content-Type: + - application/json + status: 404 Not Found + code: 404 + duration: "" +- request: + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/services/definitions/tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239 + method: GET + response: + body: | + {"data":{"type":"service-definition","id":"39c14f488ab7a1f6b54c0641478beb77","attributes":{"meta":{"last-modified-time":"2023-10-06T19:07:21Z","github-html-url":"","ingestion-source":"api","origin":"dd_terraform","origin-detail":"","warnings":[],"ingested-schema-version":"v2.2"},"schema":{"schema-version":"v2.2","dd-service":"tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239","team":"my-team","contacts":[{"name":"Team Email","type":"email","contact":"contact@datadoghq.com"}],"links":[{"name":"Architecture","type":"doc","provider":"Gigoogle drivetHub","url":"https://my-runbook"},{"name":"Runbook","type":"runbook","url":"https://my-runbook"},{"name":"Source Code","type":"repo","provider":"GitHub","url":"https://github.com/DataDog/schema"}],"tags":["my:tag","service:tag"],"integrations":{"pagerduty":{"service-url":"https://my-org.pagerduty.com/service-directory/PMyService"},"opsgenie":{"service-url":"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000","region":"US"}},"extensions":{"myorgextension":"extensionvalue"},"service-type":"web","languages":["go","python"]}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/services/definitions/tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239 + method: GET + response: + body: | + {"data":{"type":"service-definition","id":"39c14f488ab7a1f6b54c0641478beb77","attributes":{"meta":{"last-modified-time":"2023-10-06T19:07:21Z","github-html-url":"","ingestion-source":"api","origin":"dd_terraform","origin-detail":"","warnings":[],"ingested-schema-version":"v2.2"},"schema":{"schema-version":"v2.2","dd-service":"tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239","team":"my-team","contacts":[{"name":"Team Email","type":"email","contact":"contact@datadoghq.com"}],"links":[{"name":"Architecture","type":"doc","provider":"Gigoogle drivetHub","url":"https://my-runbook"},{"name":"Runbook","type":"runbook","url":"https://my-runbook"},{"name":"Source Code","type":"repo","provider":"GitHub","url":"https://github.com/DataDog/schema"}],"tags":["my:tag","service:tag"],"integrations":{"pagerduty":{"service-url":"https://my-org.pagerduty.com/service-directory/PMyService"},"opsgenie":{"service-url":"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000","region":"US"}},"extensions":{"myorgextension":"extensionvalue"},"service-type":"web","languages":["go","python"]}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/services/definitions/tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239 + method: DELETE + response: + body: "" + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content + code: 204 + duration: "" +- request: + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/services/definitions/tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239 + method: GET + response: + body: | + {"data":{"type":"service-definition","id":"39c14f488ab7a1f6b54c0641478beb77","attributes":{"meta":{"last-modified-time":"2023-10-06T19:07:21Z","github-html-url":"","ingestion-source":"api","origin":"dd_terraform","origin-detail":"","warnings":[],"ingested-schema-version":"v2.2"},"schema":{"schema-version":"v2.2","dd-service":"tf-testaccdatadogservicedefinition_basicv2_2-local-1696619239","team":"my-team","contacts":[{"name":"Team Email","type":"email","contact":"contact@datadoghq.com"}],"links":[{"name":"Architecture","type":"doc","provider":"Gigoogle drivetHub","url":"https://my-runbook"},{"name":"Runbook","type":"runbook","url":"https://my-runbook"},{"name":"Source Code","type":"repo","provider":"GitHub","url":"https://github.com/DataDog/schema"}],"tags":["my:tag","service:tag"],"integrations":{"pagerduty":{"service-url":"https://my-org.pagerduty.com/service-directory/PMyService"},"opsgenie":{"service-url":"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000","region":"US"}},"extensions":{"myorgextension":"extensionvalue"},"service-type":"web","languages":["go","python"]}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" diff --git a/datadog/tests/resource_datadog_service_definition_yaml_test.go b/datadog/tests/resource_datadog_service_definition_yaml_test.go index 925f8324f2..9442556666 100644 --- a/datadog/tests/resource_datadog_service_definition_yaml_test.go +++ b/datadog/tests/resource_datadog_service_definition_yaml_test.go @@ -58,6 +58,25 @@ func TestAccDatadogServiceDefinition_BasicV2_1(t *testing.T) { }) } +func TestAccDatadogServiceDefinition_BasicV2_2(t *testing.T) { + t.Parallel() + ctx, accProviders := testAccProviders(context.Background(), t) + uniq := strings.ToLower(uniqueEntityName(ctx, t)) + accProvider := testAccProvider(t, accProviders) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: accProviders, + CheckDestroy: testAccCheckDatadogServiceDefinitionDestroy(accProvider), + Steps: []resource.TestStep{ + { + Config: testAccCheckDatadogServiceDefinitionV2_2(uniq), + Check: checkServiceDefinitionExists(accProvider), + }, + }, + }) +} + func TestAccDatadogServiceDefinition_BasicBackstage(t *testing.T) { t.Parallel() ctx, accProviders := testAccProviders(context.Background(), t)