File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,9 +6,18 @@ import (
66 "testing"
77
88 "github.com/hetznercloud/hcloud-go/v2/hcloud"
9+ "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport"
910 "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate"
1011)
1112
13+ // GetAPIResource returns a [testsupport.GetAPIResourceFunc] for [hcloud.FloatingIP].
14+ func GetAPIResource () testsupport.GetAPIResourceFunc [hcloud.FloatingIP ] {
15+ return func (c * hcloud.Client , attrs map [string ]string ) (* hcloud.FloatingIP , error ) {
16+ result , _ , err := c .FloatingIP .Get (context .Background (), attrs ["id" ])
17+ return result , err
18+ }
19+ }
20+
1221// ByID returns a function that obtains a Floating IP by its ID.
1322func ByID (t * testing.T , fl * hcloud.FloatingIP ) func (* hcloud.Client , int64 ) bool {
1423 return func (c * hcloud.Client , id int64 ) bool {
Original file line number Diff line number Diff line change @@ -6,9 +6,18 @@ import (
66 "testing"
77
88 "github.com/hetznercloud/hcloud-go/v2/hcloud"
9+ "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport"
910 "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate"
1011)
1112
13+ // GetAPIResource returns a [testsupport.GetAPIResourceFunc] for [hcloud.LoadBalancer].
14+ func GetAPIResource () testsupport.GetAPIResourceFunc [hcloud.LoadBalancer ] {
15+ return func (c * hcloud.Client , attrs map [string ]string ) (* hcloud.LoadBalancer , error ) {
16+ result , _ , err := c .LoadBalancer .Get (context .Background (), attrs ["id" ])
17+ return result , err
18+ }
19+ }
20+
1221// ByID returns a function that obtains a loadbalancer by its ID.
1322func ByID (t * testing.T , lb * hcloud.LoadBalancer ) func (* hcloud.Client , int64 ) bool {
1423 return func (c * hcloud.Client , id int64 ) bool {
Original file line number Diff line number Diff line change @@ -6,9 +6,18 @@ import (
66 "testing"
77
88 "github.com/hetznercloud/hcloud-go/v2/hcloud"
9+ "github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport"
910 "github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate"
1011)
1112
13+ // GetAPIResource returns a [testsupport.GetAPIResourceFunc] for [hcloud.PrimaryIP].
14+ func GetAPIResource () testsupport.GetAPIResourceFunc [hcloud.PrimaryIP ] {
15+ return func (c * hcloud.Client , attrs map [string ]string ) (* hcloud.PrimaryIP , error ) {
16+ result , _ , err := c .PrimaryIP .Get (context .Background (), attrs ["id" ])
17+ return result , err
18+ }
19+ }
20+
1221// ByID returns a function that obtains a primary IP by its ID.
1322func ByID (t * testing.T , fl * hcloud.PrimaryIP ) func (* hcloud.Client , int64 ) bool {
1423 return func (c * hcloud.Client , id int64 ) bool {
You can’t perform that action at this time.
0 commit comments