feat: region adjustment for load balancer (#721)

* remove deprecated "credential" resource of loadbalancer

* region adjustment load balancer
- adapted load balancer example
This commit is contained in:
Marcel Jacek 2025-03-25 11:36:26 +01:00 committed by GitHub
parent 1444376f35
commit 176fb8408f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 250 additions and 624 deletions

View file

@ -1,6 +1,7 @@
package loadbalancer
import (
"fmt"
"testing"
"github.com/google/go-cmp/cmp"
@ -67,9 +68,12 @@ func TestToCreatePayload(t *testing.T) {
}
func TestMapFields(t *testing.T) {
const testRegion = "eu01"
id := fmt.Sprintf("%s,%s,%s", "pid", testRegion, "credentials_ref")
tests := []struct {
description string
input *loadbalancer.CredentialsResponse
region string
expected *Model
isValid bool
}{
@ -79,11 +83,13 @@ func TestMapFields(t *testing.T) {
CredentialsRef: utils.Ptr("credentials_ref"),
Username: utils.Ptr("username"),
},
testRegion,
&Model{
Id: types.StringValue("pid,credentials_ref"),
Id: types.StringValue(id),
ProjectId: types.StringValue("pid"),
CredentialsRef: types.StringValue("credentials_ref"),
Username: types.StringValue("username"),
Region: types.StringValue(testRegion),
},
true,
},
@ -95,18 +101,21 @@ func TestMapFields(t *testing.T) {
DisplayName: utils.Ptr("display_name"),
Username: utils.Ptr("username"),
},
testRegion,
&Model{
Id: types.StringValue("pid,credentials_ref"),
Id: types.StringValue(id),
ProjectId: types.StringValue("pid"),
CredentialsRef: types.StringValue("credentials_ref"),
DisplayName: types.StringValue("display_name"),
Username: types.StringValue("username"),
Region: types.StringValue(testRegion),
},
true,
},
{
"nil_response",
nil,
testRegion,
&Model{},
false,
},
@ -116,6 +125,7 @@ func TestMapFields(t *testing.T) {
CredentialsRef: utils.Ptr("credentials_ref"),
DisplayName: utils.Ptr("display_name"),
},
testRegion,
&Model{},
false,
},
@ -125,6 +135,7 @@ func TestMapFields(t *testing.T) {
DisplayName: utils.Ptr("display_name"),
Username: utils.Ptr("username"),
},
testRegion,
&Model{},
false,
},
@ -134,7 +145,7 @@ func TestMapFields(t *testing.T) {
model := &Model{
ProjectId: tt.expected.ProjectId,
}
err := mapFields(tt.input, model)
err := mapFields(tt.input, model, tt.region)
if !tt.isValid && err == nil {
t.Fatalf("Should have failed")
}