feat: SQL server beta and templates refactoring (#32)
## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Reviewed-on: #32
Reviewed-by: Andre_Harms <andre.harms@stackit.cloud>
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
This commit is contained in:
parent
4549ba63e5
commit
581e45eb9c
74 changed files with 15985 additions and 1383 deletions
|
|
@ -1,18 +1,4 @@
|
|||
// Copyright (c) STACKIT
|
||||
|
||||
package sqlserverflex
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
|
||||
)
|
||||
package sqlserverflexalpha
|
||||
|
||||
// type sqlserverflexClientMocked struct {
|
||||
// returnError bool
|
||||
|
|
@ -27,343 +13,343 @@ import (
|
|||
// return c.listFlavorsResp, nil
|
||||
// }
|
||||
|
||||
func TestMapFields(t *testing.T) {
|
||||
t.Skip("Skipping - needs refactoring")
|
||||
const testRegion = "region"
|
||||
tests := []struct {
|
||||
description string
|
||||
state Model
|
||||
input *sqlserverflex.GetInstanceResponse
|
||||
storage *storageModel
|
||||
encryption *encryptionModel
|
||||
network *networkModel
|
||||
region string
|
||||
expected Model
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
Model{
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Replicas: types.Int64Value(1),
|
||||
RetentionDays: types.Int64Value(1),
|
||||
Version: types.StringValue("v1"),
|
||||
Edition: types.StringValue("edition 1"),
|
||||
Status: types.StringValue("status"),
|
||||
IsDeletable: types.BoolValue(true),
|
||||
},
|
||||
&sqlserverflex.GetInstanceResponse{
|
||||
FlavorId: utils.Ptr("flavor_id"),
|
||||
Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(1))),
|
||||
RetentionDays: utils.Ptr(int64(1)),
|
||||
Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("v1")),
|
||||
Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition 1")),
|
||||
Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
|
||||
IsDeletable: utils.Ptr(true),
|
||||
},
|
||||
&storageModel{},
|
||||
&encryptionModel{},
|
||||
&networkModel{
|
||||
ACL: types.ListNull(basetypes.StringType{}),
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
Id: types.StringValue("pid,region,iid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringNull(),
|
||||
BackupSchedule: types.StringNull(),
|
||||
Replicas: types.Int64Value(1),
|
||||
Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
|
||||
"class": types.StringNull(),
|
||||
"size": types.Int64Null(),
|
||||
}),
|
||||
Encryption: types.ObjectValueMust(encryptionTypes, map[string]attr.Value{
|
||||
"keyring_id": types.StringNull(),
|
||||
"key_id": types.StringNull(),
|
||||
"key_version": types.StringNull(),
|
||||
"service_account": types.StringNull(),
|
||||
}),
|
||||
Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{
|
||||
"acl": types.ListNull(types.StringType),
|
||||
"access_scope": types.StringNull(),
|
||||
"instance_address": types.StringNull(),
|
||||
"router_address": types.StringNull(),
|
||||
}),
|
||||
IsDeletable: types.BoolValue(true),
|
||||
Edition: types.StringValue("edition 1"),
|
||||
Status: types.StringValue("status"),
|
||||
RetentionDays: types.Int64Value(1),
|
||||
Version: types.StringValue("v1"),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"simple_values",
|
||||
Model{
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
},
|
||||
&sqlserverflex.GetInstanceResponse{
|
||||
BackupSchedule: utils.Ptr("schedule"),
|
||||
FlavorId: utils.Ptr("flavor_id"),
|
||||
Id: utils.Ptr("iid"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
|
||||
Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
|
||||
Storage: &sqlserverflex.Storage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int64(78)),
|
||||
},
|
||||
Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition")),
|
||||
RetentionDays: utils.Ptr(int64(1)),
|
||||
Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
|
||||
IsDeletable: utils.Ptr(true),
|
||||
Encryption: nil,
|
||||
Network: &sqlserverflex.InstanceNetwork{
|
||||
AccessScope: nil,
|
||||
Acl: &[]string{
|
||||
"ip1",
|
||||
"ip2",
|
||||
"",
|
||||
},
|
||||
InstanceAddress: nil,
|
||||
RouterAddress: nil,
|
||||
},
|
||||
},
|
||||
&storageModel{},
|
||||
&encryptionModel{},
|
||||
&networkModel{
|
||||
ACL: types.ListValueMust(basetypes.StringType{}, []attr.Value{
|
||||
types.StringValue("ip1"),
|
||||
types.StringValue("ip2"),
|
||||
types.StringValue(""),
|
||||
}),
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
Id: types.StringValue("pid,region,iid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringValue("name"),
|
||||
BackupSchedule: types.StringValue("schedule"),
|
||||
Replicas: types.Int64Value(56),
|
||||
Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
|
||||
"class": types.StringValue("class"),
|
||||
"size": types.Int64Value(78),
|
||||
}),
|
||||
Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{
|
||||
"acl": types.ListValueMust(types.StringType, []attr.Value{
|
||||
types.StringValue("ip1"),
|
||||
types.StringValue("ip2"),
|
||||
types.StringValue(""),
|
||||
}),
|
||||
"access_scope": types.StringNull(),
|
||||
"instance_address": types.StringNull(),
|
||||
"router_address": types.StringNull(),
|
||||
}),
|
||||
Edition: types.StringValue("edition"),
|
||||
RetentionDays: types.Int64Value(1),
|
||||
Version: types.StringValue("version"),
|
||||
Region: types.StringValue(testRegion),
|
||||
IsDeletable: types.BoolValue(true),
|
||||
Encryption: types.ObjectValueMust(encryptionTypes, map[string]attr.Value{
|
||||
"keyring_id": types.StringNull(),
|
||||
"key_id": types.StringNull(),
|
||||
"key_version": types.StringNull(),
|
||||
"service_account": types.StringNull(),
|
||||
}),
|
||||
Status: types.StringValue("status"),
|
||||
},
|
||||
true,
|
||||
},
|
||||
// {
|
||||
// "simple_values_no_flavor_and_storage",
|
||||
// Model{
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// },
|
||||
// &sqlserverflex.GetInstanceResponse{
|
||||
// Acl: &[]string{
|
||||
// "ip1",
|
||||
// "ip2",
|
||||
// "",
|
||||
// },
|
||||
// BackupSchedule: utils.Ptr("schedule"),
|
||||
// FlavorId: nil,
|
||||
// Id: utils.Ptr("iid"),
|
||||
// Name: utils.Ptr("name"),
|
||||
// Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
|
||||
// Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
|
||||
// Storage: nil,
|
||||
// Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition")),
|
||||
// RetentionDays: utils.Ptr(int64(1)),
|
||||
// Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
|
||||
// },
|
||||
// &flavorModel{
|
||||
// CPU: types.Int64Value(12),
|
||||
// RAM: types.Int64Value(34),
|
||||
// },
|
||||
// &storageModel{
|
||||
// Class: types.StringValue("class"),
|
||||
// Size: types.Int64Value(78),
|
||||
// },
|
||||
// &optionsModel{
|
||||
// Edition: types.StringValue("edition"),
|
||||
// RetentionDays: types.Int64Value(1),
|
||||
// },
|
||||
// testRegion,
|
||||
// Model{
|
||||
// Id: types.StringValue("pid,region,iid"),
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// Name: types.StringValue("name"),
|
||||
// ACL: types.ListValueMust(types.StringType, []attr.Value{
|
||||
// types.StringValue("ip1"),
|
||||
// types.StringValue("ip2"),
|
||||
// types.StringValue(""),
|
||||
// }),
|
||||
// BackupSchedule: types.StringValue("schedule"),
|
||||
// Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
|
||||
// "id": types.StringNull(),
|
||||
// "description": types.StringNull(),
|
||||
// "cpu": types.Int64Value(12),
|
||||
// "ram": types.Int64Value(34),
|
||||
// }),
|
||||
// Replicas: types.Int64Value(56),
|
||||
// Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
|
||||
// "class": types.StringValue("class"),
|
||||
// "size": types.Int64Value(78),
|
||||
// }),
|
||||
// Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{
|
||||
// "edition": types.StringValue("edition"),
|
||||
// "retention_days": types.Int64Value(1),
|
||||
// }),
|
||||
// Version: types.StringValue("version"),
|
||||
// Region: types.StringValue(testRegion),
|
||||
// },
|
||||
// true,
|
||||
// },
|
||||
// {
|
||||
// "acls_unordered",
|
||||
// Model{
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// ACL: types.ListValueMust(types.StringType, []attr.Value{
|
||||
// types.StringValue("ip2"),
|
||||
// types.StringValue(""),
|
||||
// types.StringValue("ip1"),
|
||||
// }),
|
||||
// },
|
||||
// &sqlserverflex.GetInstanceResponse{
|
||||
// Acl: &[]string{
|
||||
// "",
|
||||
// "ip1",
|
||||
// "ip2",
|
||||
// },
|
||||
// BackupSchedule: utils.Ptr("schedule"),
|
||||
// FlavorId: nil,
|
||||
// Id: utils.Ptr("iid"),
|
||||
// Name: utils.Ptr("name"),
|
||||
// Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
|
||||
// Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
|
||||
// Storage: nil,
|
||||
// //Options: &map[string]string{
|
||||
// // "edition": "edition",
|
||||
// // "retentionDays": "1",
|
||||
// //},
|
||||
// Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
|
||||
// },
|
||||
// &flavorModel{
|
||||
// CPU: types.Int64Value(12),
|
||||
// RAM: types.Int64Value(34),
|
||||
// },
|
||||
// &storageModel{
|
||||
// Class: types.StringValue("class"),
|
||||
// Size: types.Int64Value(78),
|
||||
// },
|
||||
// &optionsModel{},
|
||||
// testRegion,
|
||||
// Model{
|
||||
// Id: types.StringValue("pid,region,iid"),
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// Name: types.StringValue("name"),
|
||||
// ACL: types.ListValueMust(types.StringType, []attr.Value{
|
||||
// types.StringValue("ip2"),
|
||||
// types.StringValue(""),
|
||||
// types.StringValue("ip1"),
|
||||
// }),
|
||||
// BackupSchedule: types.StringValue("schedule"),
|
||||
// Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
|
||||
// "id": types.StringNull(),
|
||||
// "description": types.StringNull(),
|
||||
// "cpu": types.Int64Value(12),
|
||||
// "ram": types.Int64Value(34),
|
||||
// }),
|
||||
// Replicas: types.Int64Value(56),
|
||||
// Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
|
||||
// "class": types.StringValue("class"),
|
||||
// "size": types.Int64Value(78),
|
||||
// }),
|
||||
// Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{
|
||||
// "edition": types.StringValue("edition"),
|
||||
// "retention_days": types.Int64Value(1),
|
||||
// }),
|
||||
// Version: types.StringValue("version"),
|
||||
// Region: types.StringValue(testRegion),
|
||||
// },
|
||||
// true,
|
||||
// },
|
||||
// {
|
||||
// "nil_response",
|
||||
// Model{
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// },
|
||||
// nil,
|
||||
// &flavorModel{},
|
||||
// &storageModel{},
|
||||
// &optionsModel{},
|
||||
// testRegion,
|
||||
// Model{},
|
||||
// false,
|
||||
// },
|
||||
// {
|
||||
// "no_resource_id",
|
||||
// Model{
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// },
|
||||
// &sqlserverflex.GetInstanceResponse{},
|
||||
// &flavorModel{},
|
||||
// &storageModel{},
|
||||
// &optionsModel{},
|
||||
// testRegion,
|
||||
// Model{},
|
||||
// false,
|
||||
// },
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.description, func(t *testing.T) {
|
||||
err := mapFields(context.Background(), tt.input, &tt.state, tt.storage, tt.encryption, tt.network, tt.region)
|
||||
if !tt.isValid && err == nil {
|
||||
t.Fatalf("Should have failed")
|
||||
}
|
||||
if tt.isValid && err != nil {
|
||||
t.Fatalf("Should not have failed: %v", err)
|
||||
}
|
||||
if tt.isValid {
|
||||
diff := cmp.Diff(tt.state, tt.expected)
|
||||
if diff != "" {
|
||||
t.Fatalf("Data does not match: %s", diff)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
//func TestMapFields(t *testing.T) {
|
||||
// t.Skip("Skipping - needs refactoring")
|
||||
// const testRegion = "region"
|
||||
// tests := []struct {
|
||||
// description string
|
||||
// state Model
|
||||
// input *sqlserverflex.GetInstanceResponse
|
||||
// storage *storageModel
|
||||
// encryption *encryptionModel
|
||||
// network *networkModel
|
||||
// region string
|
||||
// expected Model
|
||||
// isValid bool
|
||||
// }{
|
||||
// {
|
||||
// "default_values",
|
||||
// Model{
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// Replicas: types.Int64Value(1),
|
||||
// RetentionDays: types.Int64Value(1),
|
||||
// Version: types.StringValue("v1"),
|
||||
// Edition: types.StringValue("edition 1"),
|
||||
// Status: types.StringValue("status"),
|
||||
// IsDeletable: types.BoolValue(true),
|
||||
// },
|
||||
// &sqlserverflex.GetInstanceResponse{
|
||||
// FlavorId: utils.Ptr("flavor_id"),
|
||||
// Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(1))),
|
||||
// RetentionDays: utils.Ptr(int64(1)),
|
||||
// Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("v1")),
|
||||
// Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition 1")),
|
||||
// Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
|
||||
// IsDeletable: utils.Ptr(true),
|
||||
// },
|
||||
// &storageModel{},
|
||||
// &encryptionModel{},
|
||||
// &networkModel{
|
||||
// ACL: types.ListNull(basetypes.StringType{}),
|
||||
// },
|
||||
// testRegion,
|
||||
// Model{
|
||||
// Id: types.StringValue("pid,region,iid"),
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// Name: types.StringNull(),
|
||||
// BackupSchedule: types.StringNull(),
|
||||
// Replicas: types.Int64Value(1),
|
||||
// Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
|
||||
// "class": types.StringNull(),
|
||||
// "size": types.Int64Null(),
|
||||
// }),
|
||||
// Encryption: types.ObjectValueMust(encryptionTypes, map[string]attr.Value{
|
||||
// "keyring_id": types.StringNull(),
|
||||
// "key_id": types.StringNull(),
|
||||
// "key_version": types.StringNull(),
|
||||
// "service_account": types.StringNull(),
|
||||
// }),
|
||||
// Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{
|
||||
// "acl": types.ListNull(types.StringType),
|
||||
// "access_scope": types.StringNull(),
|
||||
// "instance_address": types.StringNull(),
|
||||
// "router_address": types.StringNull(),
|
||||
// }),
|
||||
// IsDeletable: types.BoolValue(true),
|
||||
// Edition: types.StringValue("edition 1"),
|
||||
// Status: types.StringValue("status"),
|
||||
// RetentionDays: types.Int64Value(1),
|
||||
// Version: types.StringValue("v1"),
|
||||
// Region: types.StringValue(testRegion),
|
||||
// },
|
||||
// true,
|
||||
// },
|
||||
// {
|
||||
// "simple_values",
|
||||
// Model{
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// },
|
||||
// &sqlserverflex.GetInstanceResponse{
|
||||
// BackupSchedule: utils.Ptr("schedule"),
|
||||
// FlavorId: utils.Ptr("flavor_id"),
|
||||
// Id: utils.Ptr("iid"),
|
||||
// Name: utils.Ptr("name"),
|
||||
// Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
|
||||
// Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
|
||||
// Storage: &sqlserverflex.Storage{
|
||||
// Class: utils.Ptr("class"),
|
||||
// Size: utils.Ptr(int64(78)),
|
||||
// },
|
||||
// Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition")),
|
||||
// RetentionDays: utils.Ptr(int64(1)),
|
||||
// Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
|
||||
// IsDeletable: utils.Ptr(true),
|
||||
// Encryption: nil,
|
||||
// Network: &sqlserverflex.InstanceNetwork{
|
||||
// AccessScope: nil,
|
||||
// Acl: &[]string{
|
||||
// "ip1",
|
||||
// "ip2",
|
||||
// "",
|
||||
// },
|
||||
// InstanceAddress: nil,
|
||||
// RouterAddress: nil,
|
||||
// },
|
||||
// },
|
||||
// &storageModel{},
|
||||
// &encryptionModel{},
|
||||
// &networkModel{
|
||||
// ACL: types.ListValueMust(basetypes.StringType{}, []attr.Value{
|
||||
// types.StringValue("ip1"),
|
||||
// types.StringValue("ip2"),
|
||||
// types.StringValue(""),
|
||||
// }),
|
||||
// },
|
||||
// testRegion,
|
||||
// Model{
|
||||
// Id: types.StringValue("pid,region,iid"),
|
||||
// InstanceId: types.StringValue("iid"),
|
||||
// ProjectId: types.StringValue("pid"),
|
||||
// Name: types.StringValue("name"),
|
||||
// BackupSchedule: types.StringValue("schedule"),
|
||||
// Replicas: types.Int64Value(56),
|
||||
// Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
|
||||
// "class": types.StringValue("class"),
|
||||
// "size": types.Int64Value(78),
|
||||
// }),
|
||||
// Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{
|
||||
// "acl": types.ListValueMust(types.StringType, []attr.Value{
|
||||
// types.StringValue("ip1"),
|
||||
// types.StringValue("ip2"),
|
||||
// types.StringValue(""),
|
||||
// }),
|
||||
// "access_scope": types.StringNull(),
|
||||
// "instance_address": types.StringNull(),
|
||||
// "router_address": types.StringNull(),
|
||||
// }),
|
||||
// Edition: types.StringValue("edition"),
|
||||
// RetentionDays: types.Int64Value(1),
|
||||
// Version: types.StringValue("version"),
|
||||
// Region: types.StringValue(testRegion),
|
||||
// IsDeletable: types.BoolValue(true),
|
||||
// Encryption: types.ObjectValueMust(encryptionTypes, map[string]attr.Value{
|
||||
// "keyring_id": types.StringNull(),
|
||||
// "key_id": types.StringNull(),
|
||||
// "key_version": types.StringNull(),
|
||||
// "service_account": types.StringNull(),
|
||||
// }),
|
||||
// Status: types.StringValue("status"),
|
||||
// },
|
||||
// true,
|
||||
// },
|
||||
// // {
|
||||
// // "simple_values_no_flavor_and_storage",
|
||||
// // Model{
|
||||
// // InstanceId: types.StringValue("iid"),
|
||||
// // ProjectId: types.StringValue("pid"),
|
||||
// // },
|
||||
// // &sqlserverflex.GetInstanceResponse{
|
||||
// // Acl: &[]string{
|
||||
// // "ip1",
|
||||
// // "ip2",
|
||||
// // "",
|
||||
// // },
|
||||
// // BackupSchedule: utils.Ptr("schedule"),
|
||||
// // FlavorId: nil,
|
||||
// // Id: utils.Ptr("iid"),
|
||||
// // Name: utils.Ptr("name"),
|
||||
// // Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
|
||||
// // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
|
||||
// // Storage: nil,
|
||||
// // Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition")),
|
||||
// // RetentionDays: utils.Ptr(int64(1)),
|
||||
// // Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
|
||||
// // },
|
||||
// // &flavorModel{
|
||||
// // CPU: types.Int64Value(12),
|
||||
// // RAM: types.Int64Value(34),
|
||||
// // },
|
||||
// // &storageModel{
|
||||
// // Class: types.StringValue("class"),
|
||||
// // Size: types.Int64Value(78),
|
||||
// // },
|
||||
// // &optionsModel{
|
||||
// // Edition: types.StringValue("edition"),
|
||||
// // RetentionDays: types.Int64Value(1),
|
||||
// // },
|
||||
// // testRegion,
|
||||
// // Model{
|
||||
// // Id: types.StringValue("pid,region,iid"),
|
||||
// // InstanceId: types.StringValue("iid"),
|
||||
// // ProjectId: types.StringValue("pid"),
|
||||
// // Name: types.StringValue("name"),
|
||||
// // ACL: types.ListValueMust(types.StringType, []attr.Value{
|
||||
// // types.StringValue("ip1"),
|
||||
// // types.StringValue("ip2"),
|
||||
// // types.StringValue(""),
|
||||
// // }),
|
||||
// // BackupSchedule: types.StringValue("schedule"),
|
||||
// // Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
|
||||
// // "id": types.StringNull(),
|
||||
// // "description": types.StringNull(),
|
||||
// // "cpu": types.Int64Value(12),
|
||||
// // "ram": types.Int64Value(34),
|
||||
// // }),
|
||||
// // Replicas: types.Int64Value(56),
|
||||
// // Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
|
||||
// // "class": types.StringValue("class"),
|
||||
// // "size": types.Int64Value(78),
|
||||
// // }),
|
||||
// // Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{
|
||||
// // "edition": types.StringValue("edition"),
|
||||
// // "retention_days": types.Int64Value(1),
|
||||
// // }),
|
||||
// // Version: types.StringValue("version"),
|
||||
// // Region: types.StringValue(testRegion),
|
||||
// // },
|
||||
// // true,
|
||||
// // },
|
||||
// // {
|
||||
// // "acls_unordered",
|
||||
// // Model{
|
||||
// // InstanceId: types.StringValue("iid"),
|
||||
// // ProjectId: types.StringValue("pid"),
|
||||
// // ACL: types.ListValueMust(types.StringType, []attr.Value{
|
||||
// // types.StringValue("ip2"),
|
||||
// // types.StringValue(""),
|
||||
// // types.StringValue("ip1"),
|
||||
// // }),
|
||||
// // },
|
||||
// // &sqlserverflex.GetInstanceResponse{
|
||||
// // Acl: &[]string{
|
||||
// // "",
|
||||
// // "ip1",
|
||||
// // "ip2",
|
||||
// // },
|
||||
// // BackupSchedule: utils.Ptr("schedule"),
|
||||
// // FlavorId: nil,
|
||||
// // Id: utils.Ptr("iid"),
|
||||
// // Name: utils.Ptr("name"),
|
||||
// // Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))),
|
||||
// // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")),
|
||||
// // Storage: nil,
|
||||
// // //Options: &map[string]string{
|
||||
// // // "edition": "edition",
|
||||
// // // "retentionDays": "1",
|
||||
// // //},
|
||||
// // Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")),
|
||||
// // },
|
||||
// // &flavorModel{
|
||||
// // CPU: types.Int64Value(12),
|
||||
// // RAM: types.Int64Value(34),
|
||||
// // },
|
||||
// // &storageModel{
|
||||
// // Class: types.StringValue("class"),
|
||||
// // Size: types.Int64Value(78),
|
||||
// // },
|
||||
// // &optionsModel{},
|
||||
// // testRegion,
|
||||
// // Model{
|
||||
// // Id: types.StringValue("pid,region,iid"),
|
||||
// // InstanceId: types.StringValue("iid"),
|
||||
// // ProjectId: types.StringValue("pid"),
|
||||
// // Name: types.StringValue("name"),
|
||||
// // ACL: types.ListValueMust(types.StringType, []attr.Value{
|
||||
// // types.StringValue("ip2"),
|
||||
// // types.StringValue(""),
|
||||
// // types.StringValue("ip1"),
|
||||
// // }),
|
||||
// // BackupSchedule: types.StringValue("schedule"),
|
||||
// // Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{
|
||||
// // "id": types.StringNull(),
|
||||
// // "description": types.StringNull(),
|
||||
// // "cpu": types.Int64Value(12),
|
||||
// // "ram": types.Int64Value(34),
|
||||
// // }),
|
||||
// // Replicas: types.Int64Value(56),
|
||||
// // Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{
|
||||
// // "class": types.StringValue("class"),
|
||||
// // "size": types.Int64Value(78),
|
||||
// // }),
|
||||
// // Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{
|
||||
// // "edition": types.StringValue("edition"),
|
||||
// // "retention_days": types.Int64Value(1),
|
||||
// // }),
|
||||
// // Version: types.StringValue("version"),
|
||||
// // Region: types.StringValue(testRegion),
|
||||
// // },
|
||||
// // true,
|
||||
// // },
|
||||
// // {
|
||||
// // "nil_response",
|
||||
// // Model{
|
||||
// // InstanceId: types.StringValue("iid"),
|
||||
// // ProjectId: types.StringValue("pid"),
|
||||
// // },
|
||||
// // nil,
|
||||
// // &flavorModel{},
|
||||
// // &storageModel{},
|
||||
// // &optionsModel{},
|
||||
// // testRegion,
|
||||
// // Model{},
|
||||
// // false,
|
||||
// // },
|
||||
// // {
|
||||
// // "no_resource_id",
|
||||
// // Model{
|
||||
// // InstanceId: types.StringValue("iid"),
|
||||
// // ProjectId: types.StringValue("pid"),
|
||||
// // },
|
||||
// // &sqlserverflex.GetInstanceResponse{},
|
||||
// // &flavorModel{},
|
||||
// // &storageModel{},
|
||||
// // &optionsModel{},
|
||||
// // testRegion,
|
||||
// // Model{},
|
||||
// // false,
|
||||
// // },
|
||||
// }
|
||||
// for _, tt := range tests {
|
||||
// t.Run(tt.description, func(t *testing.T) {
|
||||
// err := mapFields(context.Background(), tt.input, &tt.state, tt.storage, tt.encryption, tt.network, tt.region)
|
||||
// if !tt.isValid && err == nil {
|
||||
// t.Fatalf("Should have failed")
|
||||
// }
|
||||
// if tt.isValid && err != nil {
|
||||
// t.Fatalf("Should not have failed: %v", err)
|
||||
// }
|
||||
// if tt.isValid {
|
||||
// diff := cmp.Diff(tt.state, tt.expected)
|
||||
// if diff != "" {
|
||||
// t.Fatalf("Data does not match: %s", diff)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
|
||||
// func TestToCreatePayload(t *testing.T) {
|
||||
// tests := []struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue