// 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 (
	"fmt"
	"testing"

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

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

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

func TestAccIosxeBGPIPv6UnicastNeighbor(t *testing.T) {
	var checks []resource.TestCheckFunc
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "ip", "3.3.3.3"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "activate", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "send_community", "both"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "route_reflector_client", "false"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "soft_reconfiguration", "inbound"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "default_originate", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "default_originate_route_map", "RM1"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "route_maps.0.in_out", "in"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_ipv6_unicast_neighbor.test", "route_maps.0.route_map_name", "RM1"))
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t) },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			{
				Config: testAccIosxeBGPIPv6UnicastNeighborPrerequisitesConfig + testAccIosxeBGPIPv6UnicastNeighborConfig_minimum(),
			},
			{
				Config: testAccIosxeBGPIPv6UnicastNeighborPrerequisitesConfig + testAccIosxeBGPIPv6UnicastNeighborConfig_all(),
				Check:  resource.ComposeTestCheckFunc(checks...),
			},
			{
				ResourceName:            "iosxe_bgp_ipv6_unicast_neighbor.test",
				ImportState:             true,
				ImportStateVerify:       true,
				ImportStateIdFunc:       iosxeBGPIPv6UnicastNeighborImportStateIdFunc("iosxe_bgp_ipv6_unicast_neighbor.test"),
				ImportStateVerifyIgnore: []string{},
				Check:                   resource.ComposeTestCheckFunc(checks...),
			},
		},
	})
}

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

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

func iosxeBGPIPv6UnicastNeighborImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
	return func(s *terraform.State) (string, error) {
		primary := s.RootModule().Resources[resourceName].Primary
		Asn := primary.Attributes["asn"]
		Ip := primary.Attributes["ip"]

		return fmt.Sprintf("%s,%s", Asn, Ip), nil
	}
}

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

// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPIPv6UnicastNeighborPrerequisitesConfig = `
resource "iosxe_restconf" "PreReq0" {
	path = "Cisco-IOS-XE-native:native/ipv6"
	attributes = {
		"unicast-routing" = ""
	}
}

resource "iosxe_restconf" "PreReq1" {
	path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
	attributes = {
		"id" = "65000"
	}
}

resource "iosxe_restconf" "PreReq2" {
	path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/ipv6=unicast"
	attributes = {
		"af-name" = "unicast"
	}
	depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]
}

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

resource "iosxe_restconf" "PreReq4" {
	path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
	attributes = {
		"name" = "100"
	}
}

`

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

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

func testAccIosxeBGPIPv6UnicastNeighborConfig_minimum() string {
	config := `resource "iosxe_bgp_ipv6_unicast_neighbor" "test" {` + "\n"
	config += `	asn = "65000"` + "\n"
	config += `	ip = "3.3.3.3"` + "\n"
	config += `	depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, iosxe_restconf.PreReq4, ]` + "\n"
	config += `}` + "\n"
	return config
}

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

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

func testAccIosxeBGPIPv6UnicastNeighborConfig_all() string {
	config := `resource "iosxe_bgp_ipv6_unicast_neighbor" "test" {` + "\n"
	config += `	asn = "65000"` + "\n"
	config += `	ip = "3.3.3.3"` + "\n"
	config += `	activate = true` + "\n"
	config += `	send_community = "both"` + "\n"
	config += `	route_reflector_client = false` + "\n"
	config += `	soft_reconfiguration = "inbound"` + "\n"
	config += `	default_originate = true` + "\n"
	config += `	default_originate_route_map = "RM1"` + "\n"
	config += `	route_maps = [{` + "\n"
	config += `		in_out = "in"` + "\n"
	config += `		route_map_name = "RM1"` + "\n"
	config += `	}]` + "\n"
	config += `	depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, iosxe_restconf.PreReq4, ]` + "\n"
	config += `}` + "\n"
	return config
}

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