// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

// Code generated by "gen/generator.go"; DO NOT EDIT.

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
	"testing"

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

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource

func TestAccDataSourceIosxeBGPAddressFamilyIPv4VRF(t *testing.T) {
	var checks []resource.TestCheckFunc
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.name", "VRF1"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_advertise_l2vpn_evpn", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_redistribute_connected", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_router_id_loopback", "101"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_aggregate_addresses.0.ipv4_address", "50.0.0.0"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_aggregate_addresses.0.ipv4_mask", "255.255.0.0"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_redistribute_static", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.network", "12.0.0.0"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.mask", "255.255.0.0"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.route_map", "RM1"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.backdoor", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks.0.network", "13.0.0.0"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks.0.route_map", "RM1"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks.0.backdoor", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_admin_distances.0.distance", "200"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_admin_distances.0.source_ip", "10.1.1.1"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_admin_distances.0.wildcard", "0.0.0.0"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_distance_bgp_external", "20"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_distance_bgp_internal", "200"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_distance_bgp_local", "200"))
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t) },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			{
				Config: testAccDataSourceIosxeBGPAddressFamilyIPv4VRFPrerequisitesConfig + testAccDataSourceIosxeBGPAddressFamilyIPv4VRFConfig(),
				Check:  resource.ComposeTestCheckFunc(checks...),
			},
		},
	})
}

// End of section. //template:end testAccDataSource

// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPAddressFamilyIPv4VRFPrerequisitesConfig = `
resource "iosxe_restconf" "PreReq0" {
	path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
	delete = false
	attributes = {
		"name" = "VRF1"
		"rd" = "1:1"
		"address-family/ipv4" = ""
	}
}

resource "iosxe_restconf" "PreReq1" {
	path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
	attributes = {
		"id" = "65000"
	}
	depends_on = [iosxe_restconf.PreReq0, ]
}

resource "iosxe_restconf" "PreReq2" {
	path = "Cisco-IOS-XE-native:native/interface/Loopback=101"
	attributes = {
		"name" = "101"
		"ip/address/primary/address" = "22.22.22.22"
		"ip/address/primary/mask" = "255.255.255.255"
		"vrf/forwarding" = "VRF1"
	}
	depends_on = [iosxe_restconf.PreReq0, ]
}

`

// End of section. //template:end testPrerequisites

// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig

func testAccDataSourceIosxeBGPAddressFamilyIPv4VRFConfig() string {
	config := `resource "iosxe_bgp_address_family_ipv4_vrf" "test" {` + "\n"
	config += `	delete_mode = "attributes"` + "\n"
	config += `	asn = "65000"` + "\n"
	config += `	af_name = "unicast"` + "\n"
	config += `	vrfs = [{` + "\n"
	config += `		name = "VRF1"` + "\n"
	config += `		ipv4_unicast_advertise_l2vpn_evpn = true` + "\n"
	config += `		ipv4_unicast_redistribute_connected = true` + "\n"
	config += `		ipv4_unicast_router_id_loopback = 101` + "\n"
	config += `		ipv4_unicast_aggregate_addresses = [{` + "\n"
	config += `			ipv4_address = "50.0.0.0"` + "\n"
	config += `			ipv4_mask = "255.255.0.0"` + "\n"
	config += `		}]` + "\n"
	config += `		ipv4_unicast_redistribute_static = true` + "\n"
	config += `		ipv4_unicast_networks_mask = [{` + "\n"
	config += `			network = "12.0.0.0"` + "\n"
	config += `			mask = "255.255.0.0"` + "\n"
	config += `			route_map = "RM1"` + "\n"
	config += `			backdoor = true` + "\n"
	config += `		}]` + "\n"
	config += `		ipv4_unicast_networks = [{` + "\n"
	config += `			network = "13.0.0.0"` + "\n"
	config += `			route_map = "RM1"` + "\n"
	config += `			backdoor = true` + "\n"
	config += `		}]` + "\n"
	config += `		ipv4_unicast_admin_distances = [{` + "\n"
	config += `			distance = 200` + "\n"
	config += `			source_ip = "10.1.1.1"` + "\n"
	config += `			wildcard = "0.0.0.0"` + "\n"
	config += `		}]` + "\n"
	config += `		ipv4_unicast_distance_bgp_external = 20` + "\n"
	config += `		ipv4_unicast_distance_bgp_internal = 200` + "\n"
	config += `		ipv4_unicast_distance_bgp_local = 200` + "\n"
	config += `	}]` + "\n"
	config += `	depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
	config += `}` + "\n"

	config += `
		data "iosxe_bgp_address_family_ipv4_vrf" "test" {
			asn = "65000"
			af_name = "unicast"
			depends_on = [iosxe_bgp_address_family_ipv4_vrf.test]
		}
	`
	return config
}

// End of section. //template:end testAccDataSourceConfig
