Skip to content

Commit

Permalink
Fix test, update sample
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpedrosa authored and vaerh committed Feb 13, 2024
1 parent 6d14390 commit 216bfc1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VERSION=$(shell git describe --tags --abbrev=0)
all: docs compile checksum clean

test:
/usr/bin/go test -timeout 30s github.com/terraform-routeros/terraform-provider-routeros
go test -timeout 30s github.com/terraform-routeros/terraform-provider-routeros

docs:
go generate
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/ipv6_dhcp_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "routeros_ipv6_dhcp_client" "inet_provider" {

### Optional

- `add-default-route` (Boolean) Whether to add default IPv6 route after a client connects.
- `add_default_route` (Boolean) Whether to add default IPv6 route after a client connects.
- `comment` (String)
- `disabled` (Boolean)
- `prefix_hint ` (Number) Include a preferred prefix length.
Expand Down
9 changes: 9 additions & 0 deletions examples/resources/routeros_ipv6_dhcp_client/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ resource "routeros_ipv6_dhcp_client" "inet_provider" {
request = ["prefix"]
disabled = false
}

resource "routeros_ipv6_dhcp_client" "client" {
pool_name = "pub-add-pool"
interface = "ether1"
add-default-route = true
pool_prefix_length = "64"
request = ["prefix"]
interface = "ether1"
}
18 changes: 10 additions & 8 deletions routeros/resource_ipv6_dhcp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
// ResourceIPv6DhcpClient https://help.mikrotik.com/docs/display/ROS/DHCP#DHCP-DHCPv6Client
func ResourceIPv6DhcpClient() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/ipv6/dhcp-client/"),
MetaResourcePath: PropResourcePath("/ipv6/dhcp-client"),
MetaId: PropId(Id),

"add-default-route": {
"add_default_route": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether to add default IPv6 route after a client connects.",
Expand Down Expand Up @@ -70,16 +70,18 @@ func ResourceIPv6DhcpClient() *schema.Resource {
Computed: true,
Description: "Shows received IPv6 prefix from DHCPv6-PD server",
},
"prefix_hint ": {
Type: schema.TypeInt,
Optional: true,
Description: "Include a preferred prefix length.",
ValidateFunc: validation.IntBetween(0, 128),
"prefix_hint": {
Type: schema.TypeString,
Optional: true,
Description: "Include a preferred prefix length.",
ValidateFunc: validation.IsIPv6Address,
DiffSuppressFunc: AlwaysPresentNotUserProvided,
},
"request": {
Type: schema.TypeList,
Computed: true,
Required: true,
Description: "To choose if the DHCPv6 request will ask for the address or the IPv6 prefix, or both.",
Elem: &schema.Schema{Type: schema.TypeString},
},
"status": {
Type: schema.TypeString,
Expand Down
9 changes: 5 additions & 4 deletions routeros/resource_ipv6_dhcp_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,31 @@ func TestAccIPv6DhcpClient_basic(t *testing.T) {
testSetTransportEnv(t, name)
},
ProviderFactories: testAccProviderFactories,
CheckDestroy: testCheckResourceDestroy("/ipv6/dhcp-client/client", "routeros_ipv6_dhcp_client"),
CheckDestroy: testCheckResourceDestroy("/ipv6/dhcp-client", "routeros_ipv6_dhcp_client"),
Steps: []resource.TestStep{
{
Config: testAccIPv6DhcpClientConfig(),
Check: resource.ComposeTestCheckFunc(
testResourcePrimaryInstanceId(testIPv6DhcpClient),
resource.TestCheckResourceAttr(testIPv6DhcpClient, "interface", "ether1"),
resource.TestCheckResourceAttr(testIPv6DhcpClient, "pool_name", "inet-provider-pool"),
resource.TestCheckResourceAttr(testIPv6DhcpClient, "request.0", "prefix"),
),
},
},
})

})
}
}

func testAccIPv6DhcpClientConfig() string {
return providerConfig + `
resource "routeros_ipv6_dhcp_client" "client" {
interface = "ether1"
resource "routeros_ipv6_dhcp_client" "client" {
request = ["prefix"]
pool_name = "inet-provider-pool"
pool_prefix_length = "64"
interface = "ether1"
}
`
Expand Down

0 comments on commit 216bfc1

Please sign in to comment.