feat: region adjustments SQLServerFlex (#707)
* feat: region adjustment sqlserverflex * adapt acceptance tests * add region to internal id of sqlserverflex resources to support import of different regions
This commit is contained in:
parent
4cfdbc508f
commit
81f876adea
15 changed files with 360 additions and 105 deletions
|
|
@ -11,9 +11,11 @@ import (
|
|||
)
|
||||
|
||||
func TestMapFieldsCreate(t *testing.T) {
|
||||
const testRegion = "region"
|
||||
tests := []struct {
|
||||
description string
|
||||
input *sqlserverflex.CreateUserResponse
|
||||
region string
|
||||
expected Model
|
||||
isValid bool
|
||||
}{
|
||||
|
|
@ -25,8 +27,9 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Password: utils.Ptr(""),
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -35,6 +38,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Password: types.StringValue(""),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -54,8 +58,9 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Port: utils.Ptr(int64(1234)),
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -68,6 +73,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Password: types.StringValue("password"),
|
||||
Host: types.StringValue("host"),
|
||||
Port: types.Int64Value(1234),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -83,8 +89,9 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Port: utils.Ptr(int64(2123456789)),
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -93,18 +100,21 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Password: types.StringValue(""),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"nil_response",
|
||||
nil,
|
||||
testRegion,
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&sqlserverflex.CreateUserResponse{},
|
||||
testRegion,
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
|
|
@ -113,6 +123,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
&sqlserverflex.CreateUserResponse{
|
||||
Item: &sqlserverflex.SingleUser{},
|
||||
},
|
||||
testRegion,
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
|
|
@ -123,6 +134,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Id: utils.Ptr("uid"),
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
|
|
@ -133,7 +145,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
ProjectId: tt.expected.ProjectId,
|
||||
InstanceId: tt.expected.InstanceId,
|
||||
}
|
||||
err := mapFieldsCreate(tt.input, state)
|
||||
err := mapFieldsCreate(tt.input, state, tt.region)
|
||||
if !tt.isValid && err == nil {
|
||||
t.Fatalf("Should have failed")
|
||||
}
|
||||
|
|
@ -151,9 +163,11 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMapFields(t *testing.T) {
|
||||
const testRegion = "region"
|
||||
tests := []struct {
|
||||
description string
|
||||
input *sqlserverflex.GetUserResponse
|
||||
region string
|
||||
expected Model
|
||||
isValid bool
|
||||
}{
|
||||
|
|
@ -162,8 +176,9 @@ func TestMapFields(t *testing.T) {
|
|||
&sqlserverflex.GetUserResponse{
|
||||
Item: &sqlserverflex.UserResponseUser{},
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -171,6 +186,7 @@ func TestMapFields(t *testing.T) {
|
|||
Roles: types.SetNull(types.StringType),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -188,8 +204,9 @@ func TestMapFields(t *testing.T) {
|
|||
Port: utils.Ptr(int64(1234)),
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -199,8 +216,9 @@ func TestMapFields(t *testing.T) {
|
|||
types.StringValue("role_2"),
|
||||
types.StringValue(""),
|
||||
}),
|
||||
Host: types.StringValue("host"),
|
||||
Port: types.Int64Value(1234),
|
||||
Host: types.StringValue("host"),
|
||||
Port: types.Int64Value(1234),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -215,8 +233,9 @@ func TestMapFields(t *testing.T) {
|
|||
Port: utils.Ptr(int64(2123456789)),
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -224,18 +243,21 @@ func TestMapFields(t *testing.T) {
|
|||
Roles: types.SetValueMust(types.StringType, []attr.Value{}),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"nil_response",
|
||||
nil,
|
||||
testRegion,
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&sqlserverflex.GetUserResponse{},
|
||||
testRegion,
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
|
|
@ -244,6 +266,7 @@ func TestMapFields(t *testing.T) {
|
|||
&sqlserverflex.GetUserResponse{
|
||||
Item: &sqlserverflex.UserResponseUser{},
|
||||
},
|
||||
testRegion,
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
|
|
@ -255,7 +278,7 @@ func TestMapFields(t *testing.T) {
|
|||
InstanceId: tt.expected.InstanceId,
|
||||
UserId: tt.expected.UserId,
|
||||
}
|
||||
err := mapFields(tt.input, state)
|
||||
err := mapFields(tt.input, state, tt.region)
|
||||
if !tt.isValid && err == nil {
|
||||
t.Fatalf("Should have failed")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue