fix: adjust to new generator and sdk use
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m33s
CI Workflow / CI run tests (pull_request) Failing after 4m51s
CI Workflow / CI run build and linting (pull_request) Failing after 4m37s
CI Workflow / Code coverage report (pull_request) Has been skipped
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m33s
CI Workflow / CI run tests (pull_request) Failing after 4m51s
CI Workflow / CI run build and linting (pull_request) Failing after 4m37s
CI Workflow / Code coverage report (pull_request) Has been skipped
This commit is contained in:
parent
ca0f646526
commit
826bb5b36a
36 changed files with 2089 additions and 1166 deletions
|
|
@ -6,9 +6,8 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
|
||||
sqlserverflexbeta "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3beta1api"
|
||||
)
|
||||
|
||||
func TestMapDataSourceFields(t *testing.T) {
|
||||
|
|
@ -29,29 +28,29 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Username: types.StringNull(),
|
||||
Username: types.StringValue(""),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Host: types.StringValue(""),
|
||||
Port: types.Int64Value(0),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
DefaultDatabase: types.StringNull(),
|
||||
Status: types.StringValue(""),
|
||||
DefaultDatabase: types.StringValue(""),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"simple_values",
|
||||
&sqlserverflexbeta.GetUserResponse{
|
||||
Roles: &[]string{
|
||||
Roles: []string{
|
||||
"role_1",
|
||||
"role_2",
|
||||
"",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
Host: utils.Ptr("host"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
Status: utils.Ptr("active"),
|
||||
DefaultDatabase: utils.Ptr("default_db"),
|
||||
Username: ("username"),
|
||||
Host: ("host"),
|
||||
Port: (int32(1234)),
|
||||
Status: ("active"),
|
||||
DefaultDatabase: ("default_db"),
|
||||
},
|
||||
testRegion,
|
||||
dataSourceModel{
|
||||
|
|
@ -80,23 +79,25 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&sqlserverflexbeta.GetUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
Host: nil,
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
Id: (int64(1)),
|
||||
Roles: []string{},
|
||||
Username: "",
|
||||
Host: "",
|
||||
Port: (int32(2123456789)),
|
||||
},
|
||||
testRegion,
|
||||
dataSourceModel{
|
||||
Id: types.StringValue("pid,region,iid,1"),
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Username: types.StringNull(),
|
||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
Id: types.StringValue("pid,region,iid,1"),
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Username: types.StringValue(""),
|
||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
||||
Host: types.StringValue(""),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
DefaultDatabase: types.StringValue(""),
|
||||
Status: types.StringValue(""),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -160,8 +161,8 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"default_values",
|
||||
&sqlserverflexbeta.CreateUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Password: utils.Ptr(""),
|
||||
Id: (int64(1)),
|
||||
Password: (""),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -181,18 +182,18 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"simple_values",
|
||||
&sqlserverflexbeta.CreateUserResponse{
|
||||
Id: utils.Ptr(int64(2)),
|
||||
Roles: &[]string{
|
||||
Id: (int64(2)),
|
||||
Roles: []string{
|
||||
"role_1",
|
||||
"role_2",
|
||||
"",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
Password: utils.Ptr("password"),
|
||||
Host: utils.Ptr("host"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
Status: utils.Ptr("status"),
|
||||
DefaultDatabase: utils.Ptr("default_db"),
|
||||
Username: ("username"),
|
||||
Password: ("password"),
|
||||
Host: ("host"),
|
||||
Port: (int32(1234)),
|
||||
Status: ("status"),
|
||||
DefaultDatabase: ("default_db"),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -222,12 +223,12 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&sqlserverflexbeta.CreateUserResponse{
|
||||
Id: utils.Ptr(int64(3)),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
Password: utils.Ptr(""),
|
||||
Host: nil,
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
Id: (int64(3)),
|
||||
Roles: []string{},
|
||||
Username: "",
|
||||
Password: (""),
|
||||
Host: "",
|
||||
Port: (int32(2123456789)),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -235,14 +236,15 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
UserId: types.Int64Value(3),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Username: types.StringNull(),
|
||||
Username: types.StringValue(""),
|
||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
||||
Password: types.StringValue(""),
|
||||
Host: types.StringNull(),
|
||||
Host: types.StringValue(""),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
DefaultDatabase: types.StringNull(),
|
||||
Status: types.StringNull(),
|
||||
DefaultDatabase: types.StringValue(""),
|
||||
Status: types.StringValue(""),
|
||||
Uri: types.StringValue(""),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -253,29 +255,20 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
resourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&sqlserverflexbeta.CreateUserResponse{},
|
||||
testRegion,
|
||||
resourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&sqlserverflexbeta.CreateUserResponse{},
|
||||
testRegion,
|
||||
resourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_password",
|
||||
&sqlserverflexbeta.CreateUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{},
|
||||
false,
|
||||
},
|
||||
//{
|
||||
// "nil_response_2",
|
||||
// &sqlserverflexbeta.CreateUserResponse{},
|
||||
// testRegion,
|
||||
// resourceModel{},
|
||||
// false,
|
||||
//},
|
||||
//{
|
||||
// "no_resource_id",
|
||||
// &sqlserverflexbeta.CreateUserResponse{},
|
||||
// testRegion,
|
||||
// resourceModel{},
|
||||
// false,
|
||||
//},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(
|
||||
|
|
@ -320,10 +313,10 @@ func TestMapFields(t *testing.T) {
|
|||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Username: types.StringNull(),
|
||||
Username: types.StringValue(""),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Host: types.StringValue(""),
|
||||
Port: types.Int64Value(0),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
|
|
@ -331,14 +324,14 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"simple_values",
|
||||
&sqlserverflexbeta.GetUserResponse{
|
||||
Roles: &[]string{
|
||||
Roles: []string{
|
||||
"role_2",
|
||||
"role_1",
|
||||
"",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
Host: utils.Ptr("host"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
Username: ("username"),
|
||||
Host: ("host"),
|
||||
Port: (int32(1234)),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -365,11 +358,11 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&sqlserverflexbeta.GetUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
Host: nil,
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
Id: (int64(1)),
|
||||
Roles: []string{},
|
||||
Username: "",
|
||||
Host: "",
|
||||
Port: (int32(2123456789)),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -377,9 +370,9 @@ func TestMapFields(t *testing.T) {
|
|||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Username: types.StringNull(),
|
||||
Username: types.StringValue(""),
|
||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
||||
Host: types.StringNull(),
|
||||
Host: types.StringValue(""),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
|
|
@ -446,8 +439,8 @@ func TestToCreatePayload(t *testing.T) {
|
|||
&resourceModel{},
|
||||
[]string{},
|
||||
&sqlserverflexbeta.CreateUserRequestPayload{
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
Roles: []string{},
|
||||
Username: "",
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -461,27 +454,27 @@ func TestToCreatePayload(t *testing.T) {
|
|||
"role_2",
|
||||
},
|
||||
&sqlserverflexbeta.CreateUserRequestPayload{
|
||||
Roles: &[]string{
|
||||
Roles: []string{
|
||||
"role_1",
|
||||
"role_2",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
Username: ("username"),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&resourceModel{
|
||||
Username: types.StringNull(),
|
||||
Username: types.StringValue(""),
|
||||
},
|
||||
[]string{
|
||||
"",
|
||||
},
|
||||
&sqlserverflexbeta.CreateUserRequestPayload{
|
||||
Roles: &[]string{
|
||||
Roles: []string{
|
||||
"",
|
||||
},
|
||||
Username: nil,
|
||||
Username: "",
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -499,8 +492,8 @@ func TestToCreatePayload(t *testing.T) {
|
|||
},
|
||||
[]string{},
|
||||
&sqlserverflexbeta.CreateUserRequestPayload{
|
||||
Roles: &[]string{},
|
||||
Username: utils.Ptr("username"),
|
||||
Roles: []string{},
|
||||
Username: ("username"),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue