// Code generated by "gen/generator.go"; DO NOT EDIT.
// In order to regenerate this file execute `go generate` from the repository root.
// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md).

package provider

import (
	"regexp"
	"testing"

	"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccResourceTagAnnotationWithFvTenant(t *testing.T) {

	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "both", "3.2(1l)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigTagAnnotationMinDependencyWithFvTenantAllowExisting,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.allow_test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test_2", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test", "value", "test_value"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test_2", "value", "test_value"),
				),
			},
		},
	})

	setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false")
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "both", "3.2(1l)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:      testConfigTagAnnotationMinDependencyWithFvTenantAllowExisting,
				ExpectError: regexp.MustCompile("Object Already Exists"),
			},
		},
	})

	setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true")
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "both", "3.2(1l)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigTagAnnotationMinDependencyWithFvTenantAllowExisting,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.allow_test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test_2", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test", "value", "test_value"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test_2", "value", "test_value"),
				),
			},
		},
	})

	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "both", "3.2(1l)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigTagAnnotationMinDependencyWithFvTenant,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.test", "value", "test_value"),
				),
			},
			// Update with all config and verify default APIC values
			{
				Config:             testConfigTagAnnotationAllDependencyWithFvTenant,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.test", "value", "value_1"),
				),
			},
			// Update with minimum config and verify config is unchanged
			{
				Config:             testConfigTagAnnotationMinDependencyWithFvTenant,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.test", "value", "test_value"),
				),
			},
			// Update with empty strings config or default value
			{
				Config:             testConfigTagAnnotationResetDependencyWithFvTenant,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.test", "value", "test_value"),
				),
			},
			// Import testing
			{
				ResourceName:      "aci_annotation.test",
				ImportState:       true,
				ImportStateVerify: true,
			},
		},
		CheckDestroy: testCheckResourceDestroy,
	})
}
func TestAccResourceTagAnnotationWithFvAEPg(t *testing.T) {

	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "both", "3.2(1l)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigTagAnnotationMinDependencyWithFvAEPgAllowExisting,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.allow_test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test_2", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test", "value", "test_value"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test_2", "value", "test_value"),
				),
			},
		},
	})

	setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false")
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "both", "3.2(1l)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:      testConfigTagAnnotationMinDependencyWithFvAEPgAllowExisting,
				ExpectError: regexp.MustCompile("Object Already Exists"),
			},
		},
	})

	setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true")
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "both", "3.2(1l)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigTagAnnotationMinDependencyWithFvAEPgAllowExisting,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.allow_test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test_2", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test", "value", "test_value"),
					resource.TestCheckResourceAttr("aci_annotation.allow_test_2", "value", "test_value"),
				),
			},
		},
	})

	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "both", "3.2(1l)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigTagAnnotationMinDependencyWithFvAEPg,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.test", "value", "test_value"),
				),
			},
			// Update with all config and verify default APIC values
			{
				Config:             testConfigTagAnnotationAllDependencyWithFvAEPg,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.test", "value", "value_1"),
				),
			},
			// Update with minimum config and verify config is unchanged
			{
				Config:             testConfigTagAnnotationMinDependencyWithFvAEPg,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.test", "value", "test_value"),
				),
			},
			// Update with empty strings config or default value
			{
				Config:             testConfigTagAnnotationResetDependencyWithFvAEPg,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_annotation.test", "key", "test_key"),
					resource.TestCheckResourceAttr("aci_annotation.test", "value", "test_value"),
				),
			},
			// Import testing
			{
				ResourceName:      "aci_annotation.test",
				ImportState:       true,
				ImportStateVerify: true,
			},
		},
		CheckDestroy: testCheckResourceDestroy,
	})
}

const testConfigTagAnnotationMinDependencyWithFvTenantAllowExisting = testConfigFvTenantMin + `
resource "aci_annotation" "allow_test" {
  parent_dn = aci_tenant.test.id
  key = "test_key"
  value = "test_value"
}
resource "aci_annotation" "allow_test_2" {
  parent_dn = aci_tenant.test.id
  key = "test_key"
  value = "test_value"
  depends_on = [aci_annotation.allow_test]
}
`

const testConfigTagAnnotationMinDependencyWithFvTenant = testConfigFvTenantMin + `
resource "aci_annotation" "test" {
  parent_dn = aci_tenant.test.id
  key = "test_key"
  value = "test_value"
}
`

const testConfigTagAnnotationAllDependencyWithFvTenant = testConfigFvTenantMin + `
resource "aci_annotation" "test" {
  parent_dn = aci_tenant.test.id
  key = "test_key"
  value = "value_1"
}
`

const testConfigTagAnnotationResetDependencyWithFvTenant = testConfigFvTenantMin + `
resource "aci_annotation" "test" {
  parent_dn = aci_tenant.test.id
  key = "test_key"
  value = "test_value"
}
`

const testConfigTagAnnotationMinDependencyWithFvAEPgAllowExisting = testConfigFvAEPgMin + `
resource "aci_annotation" "allow_test" {
  parent_dn = aci_application_epg.test.id
  key = "test_key"
  value = "test_value"
}
resource "aci_annotation" "allow_test_2" {
  parent_dn = aci_application_epg.test.id
  key = "test_key"
  value = "test_value"
  depends_on = [aci_annotation.allow_test]
}
`

const testConfigTagAnnotationMinDependencyWithFvAEPg = testConfigFvAEPgMin + `
resource "aci_annotation" "test" {
  parent_dn = aci_application_epg.test.id
  key = "test_key"
  value = "test_value"
}
`

const testConfigTagAnnotationAllDependencyWithFvAEPg = testConfigFvAEPgMin + `
resource "aci_annotation" "test" {
  parent_dn = aci_application_epg.test.id
  key = "test_key"
  value = "value_1"
}
`

const testConfigTagAnnotationResetDependencyWithFvAEPg = testConfigFvAEPgMin + `
resource "aci_annotation" "test" {
  parent_dn = aci_application_epg.test.id
  key = "test_key"
  value = "test_value"
}
`
