From 5831d9129d68484451912e0beba2137641a306e5 Mon Sep 17 00:00:00 2001 From: danischm Date: Mon, 10 Jun 2024 15:13:12 +0200 Subject: [PATCH] Fix tests --- docs/resources/bgp_peer.md | 1 - docs/resources/bgp_peer_local_asn.md | 2 +- examples/resources/nxos_bgp_peer_local_asn/resource.tf | 2 +- gen/definitions/bgp_peer.yaml | 3 ++- gen/definitions/bgp_peer_local_asn.yaml | 6 +----- .../provider/data_source_nxos_bgp_peer_local_asn_test.go | 6 ++---- internal/provider/data_source_nxos_bgp_peer_test.go | 2 -- internal/provider/model_nxos_bgp_peer.go | 2 +- internal/provider/resource_nxos_bgp_peer.go | 4 +--- internal/provider/resource_nxos_bgp_peer_local_asn_test.go | 6 ++---- internal/provider/resource_nxos_bgp_peer_test.go | 2 -- 11 files changed, 11 insertions(+), 25 deletions(-) diff --git a/docs/resources/bgp_peer.md b/docs/resources/bgp_peer.md index 73265af4..84b24289 100644 --- a/docs/resources/bgp_peer.md +++ b/docs/resources/bgp_peer.md @@ -77,7 +77,6 @@ resource "nxos_bgp_peer" "example" { - `password` (String) Password. - `password_type` (String) Password Encryption Type. - Choices: `0`, `3`, `LINE`, `7` - - Default value: `LINE` - `peer_control` (String) Peer Controls. - Choices: `bfd`, `dis-conn-check`, `cap-neg-off`, `no-dyn-cap` - `peer_template` (String) Peer template name. diff --git a/docs/resources/bgp_peer_local_asn.md b/docs/resources/bgp_peer_local_asn.md index 18a9be64..07fee032 100644 --- a/docs/resources/bgp_peer_local_asn.md +++ b/docs/resources/bgp_peer_local_asn.md @@ -23,7 +23,7 @@ This resource can manage the BGP peer local asn configuration. ```terraform resource "nxos_bgp_peer_local_asn" "example" { - asn_propagation = "prepend" + asn_propagation = "no-prepend" local_asn = "65001" vrf = "default" address = "192.168.0.1" diff --git a/examples/resources/nxos_bgp_peer_local_asn/resource.tf b/examples/resources/nxos_bgp_peer_local_asn/resource.tf index 4e7ec4cb..eba1f4ef 100644 --- a/examples/resources/nxos_bgp_peer_local_asn/resource.tf +++ b/examples/resources/nxos_bgp_peer_local_asn/resource.tf @@ -1,5 +1,5 @@ resource "nxos_bgp_peer_local_asn" "example" { - asn_propagation = "prepend" + asn_propagation = "no-prepend" local_asn = "65001" vrf = "default" address = "192.168.0.1" diff --git a/gen/definitions/bgp_peer.yaml b/gen/definitions/bgp_peer.yaml index 6bccb747..721d79cb 100644 --- a/gen/definitions/bgp_peer.yaml +++ b/gen/definitions/bgp_peer.yaml @@ -108,7 +108,8 @@ attributes: - LINE - "7" example: LINE - default_value: LINE + exclude_test: true + omit_empty_value: true - nxos_name: password tf_name: password description: "Password." diff --git a/gen/definitions/bgp_peer_local_asn.yaml b/gen/definitions/bgp_peer_local_asn.yaml index a48f9ba0..454598e9 100644 --- a/gen/definitions/bgp_peer_local_asn.yaml +++ b/gen/definitions/bgp_peer_local_asn.yaml @@ -19,7 +19,7 @@ attributes: - no-prepend - replace-as - dual-as - example: prepend + example: no-prepend - nxos_name: localAsn tf_name: local_asn type: String @@ -67,10 +67,6 @@ test_prerequisites: - dn: sys/bgp/inst/dom-[default]/peer-[192.168.0.1] class_name: bgpPeer attributes: - - name: bgp_asn - value: "65001" - - name: vrf_name - value: default - name: addr value: "192.168.0.1" - name: asn diff --git a/internal/provider/data_source_nxos_bgp_peer_local_asn_test.go b/internal/provider/data_source_nxos_bgp_peer_local_asn_test.go index f8cbc41d..2105f982 100644 --- a/internal/provider/data_source_nxos_bgp_peer_local_asn_test.go +++ b/internal/provider/data_source_nxos_bgp_peer_local_asn_test.go @@ -33,7 +33,7 @@ func TestAccDataSourceNxosBGPPeerLocalASN(t *testing.T) { { Config: testAccDataSourceNxosBGPPeerLocalASNPrerequisitesConfig + testAccDataSourceNxosBGPPeerLocalASNConfig, Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.nxos_bgp_peer_local_asn.test", "asn_propagation", "prepend"), + resource.TestCheckResourceAttr("data.nxos_bgp_peer_local_asn.test", "asn_propagation", "no-prepend"), resource.TestCheckResourceAttr("data.nxos_bgp_peer_local_asn.test", "local_asn", "65001"), ), }, @@ -80,8 +80,6 @@ resource "nxos_rest" "PreReq4" { dn = "sys/bgp/inst/dom-[default]/peer-[192.168.0.1]" class_name = "bgpPeer" content = { - bgp_asn = "65001" - vrf_name = "default" addr = "192.168.0.1" asn = "65002" } @@ -93,7 +91,7 @@ resource "nxos_rest" "PreReq4" { const testAccDataSourceNxosBGPPeerLocalASNConfig = ` resource "nxos_bgp_peer_local_asn" "test" { - asn_propagation = "prepend" + asn_propagation = "no-prepend" local_asn = "65001" vrf = "default" address = "192.168.0.1" diff --git a/internal/provider/data_source_nxos_bgp_peer_test.go b/internal/provider/data_source_nxos_bgp_peer_test.go index 246171c2..688808dc 100644 --- a/internal/provider/data_source_nxos_bgp_peer_test.go +++ b/internal/provider/data_source_nxos_bgp_peer_test.go @@ -43,7 +43,6 @@ func TestAccDataSourceNxosBGPPeer(t *testing.T) { resource.TestCheckResourceAttr("data.nxos_bgp_peer.test", "keepalive", "15"), resource.TestCheckResourceAttr("data.nxos_bgp_peer.test", "ebgp_multihop_ttl", "5"), resource.TestCheckResourceAttr("data.nxos_bgp_peer.test", "peer_control", "bfd"), - resource.TestCheckResourceAttr("data.nxos_bgp_peer.test", "password_type", "LINE"), ), }, }, @@ -102,7 +101,6 @@ resource "nxos_bgp_peer" "test" { keepalive = 15 ebgp_multihop_ttl = 5 peer_control = "bfd" - password_type = "LINE" password = "secret_password" depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, ] } diff --git a/internal/provider/model_nxos_bgp_peer.go b/internal/provider/model_nxos_bgp_peer.go index 35387f34..951ba2ac 100644 --- a/internal/provider/model_nxos_bgp_peer.go +++ b/internal/provider/model_nxos_bgp_peer.go @@ -89,7 +89,7 @@ func (data BGPPeer) toBody() nxos.Body { if (!data.PeerControl.IsUnknown() && !data.PeerControl.IsNull()) || true { body, _ = sjson.Set(body, data.getClassName()+".attributes."+"ctrl", data.PeerControl.ValueString()) } - if (!data.PasswordType.IsUnknown() && !data.PasswordType.IsNull()) || true { + if (!data.PasswordType.IsUnknown() && !data.PasswordType.IsNull()) || false { body, _ = sjson.Set(body, data.getClassName()+".attributes."+"passwdType", data.PasswordType.ValueString()) } if (!data.Password.IsUnknown() && !data.Password.IsNull()) || true { diff --git a/internal/provider/resource_nxos_bgp_peer.go b/internal/provider/resource_nxos_bgp_peer.go index 8277e065..91752258 100644 --- a/internal/provider/resource_nxos_bgp_peer.go +++ b/internal/provider/resource_nxos_bgp_peer.go @@ -153,10 +153,8 @@ func (r *BGPPeerResource) Schema(ctx context.Context, req resource.SchemaRequest }, }, "password_type": schema.StringAttribute{ - MarkdownDescription: helpers.NewAttributeDescription("Password Encryption Type.").AddStringEnumDescription("0", "3", "LINE", "7").AddDefaultValueDescription("LINE").String, + MarkdownDescription: helpers.NewAttributeDescription("Password Encryption Type.").AddStringEnumDescription("0", "3", "LINE", "7").String, Optional: true, - Computed: true, - Default: stringdefault.StaticString("LINE"), Validators: []validator.String{ stringvalidator.OneOf("0", "3", "LINE", "7"), }, diff --git a/internal/provider/resource_nxos_bgp_peer_local_asn_test.go b/internal/provider/resource_nxos_bgp_peer_local_asn_test.go index 434dd2ad..cacd1812 100644 --- a/internal/provider/resource_nxos_bgp_peer_local_asn_test.go +++ b/internal/provider/resource_nxos_bgp_peer_local_asn_test.go @@ -33,7 +33,7 @@ func TestAccNxosBGPPeerLocalASN(t *testing.T) { { Config: testAccNxosBGPPeerLocalASNPrerequisitesConfig + testAccNxosBGPPeerLocalASNConfig_all(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("nxos_bgp_peer_local_asn.test", "asn_propagation", "prepend"), + resource.TestCheckResourceAttr("nxos_bgp_peer_local_asn.test", "asn_propagation", "no-prepend"), resource.TestCheckResourceAttr("nxos_bgp_peer_local_asn.test", "local_asn", "65001"), resource.TestCheckResourceAttr("nxos_bgp_peer_local_asn.test", "vrf", "default"), resource.TestCheckResourceAttr("nxos_bgp_peer_local_asn.test", "address", "192.168.0.1"), @@ -87,8 +87,6 @@ resource "nxos_rest" "PreReq4" { dn = "sys/bgp/inst/dom-[default]/peer-[192.168.0.1]" class_name = "bgpPeer" content = { - bgp_asn = "65001" - vrf_name = "default" addr = "192.168.0.1" asn = "65002" } @@ -111,7 +109,7 @@ func testAccNxosBGPPeerLocalASNConfig_minimum() string { func testAccNxosBGPPeerLocalASNConfig_all() string { return ` resource "nxos_bgp_peer_local_asn" "test" { - asn_propagation = "prepend" + asn_propagation = "no-prepend" local_asn = "65001" vrf = "default" address = "192.168.0.1" diff --git a/internal/provider/resource_nxos_bgp_peer_test.go b/internal/provider/resource_nxos_bgp_peer_test.go index b3202a6d..bf9919cf 100644 --- a/internal/provider/resource_nxos_bgp_peer_test.go +++ b/internal/provider/resource_nxos_bgp_peer_test.go @@ -45,7 +45,6 @@ func TestAccNxosBGPPeer(t *testing.T) { resource.TestCheckResourceAttr("nxos_bgp_peer.test", "keepalive", "15"), resource.TestCheckResourceAttr("nxos_bgp_peer.test", "ebgp_multihop_ttl", "5"), resource.TestCheckResourceAttr("nxos_bgp_peer.test", "peer_control", "bfd"), - resource.TestCheckResourceAttr("nxos_bgp_peer.test", "password_type", "LINE"), resource.TestCheckResourceAttr("nxos_bgp_peer.test", "password", "secret_password"), ), }, @@ -121,7 +120,6 @@ func testAccNxosBGPPeerConfig_all() string { keepalive = 15 ebgp_multihop_ttl = 5 peer_control = "bfd" - password_type = "LINE" password = "secret_password" depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, ] }