Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions mso/datasource_mso_schema_template_anp_epg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ func TestAccMSOSchemaTemplateAnpEpgDatasource(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckMSOSchemaTemplateAnpEpgDestroy,
Steps: []resource.TestStep{
{
PreConfig: func() { fmt.Println("Test: Read EPG datasource not found error") },
Config: testAccMSOSchemaTemplateAnpEpgDatasourceNotFound(),
ExpectError: regexp.MustCompile("Unable to find the ANP EPG"),
},
{
PreConfig: func() { fmt.Println("Test: Read EPG datasource") },
Config: testAccMSOSchemaTemplateAnpEpgDatasource(),
Expand All @@ -25,11 +30,6 @@ func TestAccMSOSchemaTemplateAnpEpgDatasource(t *testing.T) {
resource.TestCheckResourceAttr("data.mso_schema_template_anp_epg.epg", "display_name", msoSchemaTemplateAnpEpgName),
),
},
{
PreConfig: func() { fmt.Println("Test: Read EPG datasource not found error") },
Config: testAccMSOSchemaTemplateAnpEpgDatasourceNotFound(),
ExpectError: regexp.MustCompile("Unable to find the ANP EPG"),
},
},
})
}
Expand Down
10 changes: 5 additions & 5 deletions mso/datasource_mso_schema_template_anp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ func TestAccMSOSchemaTemplateAnpDatasource(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckMSOSchemaTemplateAnpDestroy,
Steps: []resource.TestStep{
{
PreConfig: func() { fmt.Println("Test: Read ANP datasource not found error") },
Config: testAccMSOSchemaTemplateAnpDatasourceNotFound(),
ExpectError: regexp.MustCompile("Unable to find the ANP"),
},
{
PreConfig: func() { fmt.Println("Test: Read ANP datasource") },
Config: testAccMSOSchemaTemplateAnpDatasource(),
Expand All @@ -24,11 +29,6 @@ func TestAccMSOSchemaTemplateAnpDatasource(t *testing.T) {
resource.TestCheckResourceAttr("data.mso_schema_template_anp.anp", "display_name", msoSchemaTemplateAnpName),
),
},
{
PreConfig: func() { fmt.Println("Test: Read ANP datasource not found error") },
Config: testAccMSOSchemaTemplateAnpDatasourceNotFound(),
ExpectError: regexp.MustCompile("Unable to find the ANP"),
},
},
})
}
Expand Down
1 change: 1 addition & 0 deletions mso/datasource_mso_schema_template_vrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func datasourceMSOSchemaTemplateVrfRead(d *schema.ResourceData, m interface{}) e

if !found {
d.SetId("")
return fmt.Errorf("Unable to find the VRF %s in Template %s of Schema Id %s ", vrfName, templateName, schemaId)
}
log.Printf("[DEBUG] %s: Read finished successfully", d.Id())
return nil
Expand Down
80 changes: 61 additions & 19 deletions mso/datasource_mso_schema_template_vrf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,81 @@ package mso

import (
"fmt"
"regexp"
"testing"

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

func TestAccMSOSchemaTemplateVrfDataSource(t *testing.T) {
func TestAccMSOSchemaTemplateVrfDatasource(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMSOSchemaTemplateVrfDestroy,
Steps: []resource.TestStep{
{
PreConfig: func() { fmt.Println("Test: Schema Template VRF Data Source") },
Config: testAccMSOSchemaTemplateVrfDataSource(),
PreConfig: func() { fmt.Println("Test: Read VRF datasource not found error") },
Config: testAccMSOSchemaTemplateVrfDatasourceNotFound(),
ExpectError: regexp.MustCompile("Unable to find the VRF"),
},
{
PreConfig: func() { fmt.Println("Test: Read VRF datasource") },
Config: testAccMSOSchemaTemplateVrfDatasource(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.schema_template_vrf", "name", "tf_test_schema_template_vrf"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.schema_template_vrf", "description", "Terraform test Schema Template VRF"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.schema_template_vrf", "display_name", "tf_test_schema_template_vrf"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.schema_template_vrf", "ip_data_plane_learning", "enabled"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.schema_template_vrf", "vzany", "false"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.schema_template_vrf", "preferred_group", "false"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.schema_template_vrf", "site_aware_policy_enforcement", "false"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.schema_template_vrf", "layer3_multicast", "false"),
resource.TestCheckResourceAttrSet("data.mso_schema_template_vrf.vrf", "schema_id"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "template", msoSchemaTemplateName),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "name", msoSchemaTemplateVrfName),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "display_name", msoSchemaTemplateVrfName),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "description", "Terraform test VRF"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "ip_data_plane_learning", "enabled"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "vzany", "false"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "preferred_group", "false"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "site_aware_policy_enforcement", "false"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "layer3_multicast", "true"),
resource.TestCheckResourceAttr("data.mso_schema_template_vrf.vrf", "rendezvous_points.#", "1"),
customTestCheckResourceTypeSetAttr("data.mso_schema_template_vrf.vrf", "rendezvous_points",
map[string]string{
"ip_address": "1.1.1.2",
"type": "static",
},
),
),
},
},
})
}

func testAccMSOSchemaTemplateVrfDataSource() string {
func testAccMSOSchemaTemplateVrfDatasourceConfig() string {
return fmt.Sprintf(`%[1]s
resource "mso_schema_template_vrf" "%[2]s" {
schema_id = mso_schema.%[3]s.id
template = "%[4]s"
name = "%[2]s"
display_name = "%[2]s"
description = "Terraform test VRF"
layer3_multicast = true
rendezvous_points {
ip_address = "1.1.1.2"
type = "static"
route_map_policy_multicast_uuid = mso_tenant_policies_route_map_policy_multicast.route_map_policy_multicast.uuid
}
}`, testAccMSOSchemaTemplateVrfPrerequisiteConfig(), msoSchemaTemplateVrfName, msoSchemaName, msoSchemaTemplateName)
}

func testAccMSOSchemaTemplateVrfDatasource() string {
return fmt.Sprintf(`%s
data "mso_schema_template_vrf" "vrf" {
schema_id = mso_schema.%[2]s.id
template = "%[3]s"
name = mso_schema_template_vrf.%[4]s.name
}`, testAccMSOSchemaTemplateVrfDatasourceConfig(), msoSchemaName, msoSchemaTemplateName, msoSchemaTemplateVrfName)
}

func testAccMSOSchemaTemplateVrfDatasourceNotFound() string {
return fmt.Sprintf(`%s
data "mso_schema_template_vrf" "schema_template_vrf" {
schema_id = mso_schema_template_vrf.schema_template_vrf.schema_id
template = mso_schema_template_vrf.schema_template_vrf.template
name = "tf_test_schema_template_vrf"
}`, testAccMSOSchemaTemplateVrfConfigCreate())
data "mso_schema_template_vrf" "vrf" {
schema_id = mso_schema.%[2]s.id
template = "%[3]s"
name = "non_existing_vrf_name"
}`, testAccMSOSchemaTemplateVrfDatasourceConfig(), msoSchemaName, msoSchemaTemplateName)
}
Loading
Loading