fix: refactor tests
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m27s
CI Workflow / CI run tests (pull_request) Failing after 4m54s
CI Workflow / CI run build and linting (pull_request) Failing after 4m39s
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 3m27s
CI Workflow / CI run tests (pull_request) Failing after 4m54s
CI Workflow / CI run build and linting (pull_request) Failing after 4m39s
CI Workflow / Code coverage report (pull_request) Has been skipped
This commit is contained in:
parent
826bb5b36a
commit
c7260e04e2
19 changed files with 521 additions and 938 deletions
|
|
@ -171,7 +171,7 @@ func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgre
|
|||
postgresflexalphadatasource.WriteValue{}.AttributeTypes(ctx),
|
||||
map[string]attr.Value{
|
||||
"host": types.StringValue(resp.ConnectionInfo.Write.Host),
|
||||
"port": types.Int32Value(resp.ConnectionInfo.Write.Port),
|
||||
"port": types.Int64Value(int64(resp.ConnectionInfo.Write.Port)),
|
||||
},
|
||||
),
|
||||
},
|
||||
|
|
@ -180,7 +180,7 @@ func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgre
|
|||
}
|
||||
|
||||
func handleNetwork(ctx context.Context, m *dataSourceModel, resp *postgresflex.GetInstanceResponse) error {
|
||||
netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
|
||||
netACL, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
|
||||
if diags.HasError() {
|
||||
return fmt.Errorf("failed converting network acl from response")
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ func handleNetwork(ctx context.Context, m *dataSourceModel, resp *postgresflex.G
|
|||
postgresflexalphadatasource.NetworkValue{}.AttributeTypes(ctx),
|
||||
map[string]attr.Value{
|
||||
"access_scope": types.StringValue(string(resp.Network.GetAccessScope())),
|
||||
"acl": netAcl,
|
||||
"acl": netACL,
|
||||
"instance_address": types.StringValue(instAddr),
|
||||
"router_address": types.StringValue(rtrAddr),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func Test_handleConnectionInfo(t *testing.T) {
|
|||
ConnectionInfo: postgresflex.InstanceConnectionInfo{
|
||||
Write: postgresflex.InstanceConnectionInfoWrite{
|
||||
Host: tt.args.hostName,
|
||||
Port: tt.args.port,
|
||||
Port: int32(tt.args.port),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ func Test_handleConnectionInfo(t *testing.T) {
|
|||
if !ok {
|
||||
t.Errorf("could not find a value for port in connection_info.write")
|
||||
}
|
||||
if !gotPort.Equal(types.Int32Value(tt.args.port)) {
|
||||
if !gotPort.Equal(types.Int64Value(int64(tt.args.port))) {
|
||||
t.Errorf("port value incorrect: want: %d - got: %s", tt.args.port, gotPort.String())
|
||||
}
|
||||
}
|
||||
|
|
@ -102,6 +102,7 @@ func Test_handleConnectionInfo(t *testing.T) {
|
|||
}
|
||||
|
||||
func Test_handleEncryption(t *testing.T) {
|
||||
t.Skipf("please implement")
|
||||
type args struct {
|
||||
m *dataSourceModel
|
||||
resp *postgresflex.GetInstanceResponse
|
||||
|
|
@ -121,6 +122,7 @@ func Test_handleEncryption(t *testing.T) {
|
|||
}
|
||||
|
||||
func Test_handleNetwork(t *testing.T) {
|
||||
t.Skipf("please implement")
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
m *dataSourceModel
|
||||
|
|
@ -143,6 +145,7 @@ func Test_handleNetwork(t *testing.T) {
|
|||
}
|
||||
|
||||
func Test_mapGetDataInstanceResponseToModel(t *testing.T) {
|
||||
t.Skipf("please implement")
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
m *dataSourceModel
|
||||
|
|
@ -165,6 +168,7 @@ func Test_mapGetDataInstanceResponseToModel(t *testing.T) {
|
|||
}
|
||||
|
||||
func Test_mapGetInstanceResponseToModel(t *testing.T) {
|
||||
t.Skipf("please implement")
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
m *postgresflexalpharesource.InstanceModel
|
||||
|
|
|
|||
|
|
@ -169,11 +169,11 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringNull(),
|
||||
Name: types.StringValue(""),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Password: types.StringNull(),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
Status: types.StringValue(""),
|
||||
//ConnectionString: types.StringNull(),
|
||||
},
|
||||
true,
|
||||
|
|
@ -213,11 +213,11 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringNull(),
|
||||
Name: types.StringValue(""),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Password: types.StringNull(),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
Status: types.StringValue(""),
|
||||
//ConnectionString: types.StringNull(),
|
||||
},
|
||||
true,
|
||||
|
|
@ -260,7 +260,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
t.Fatalf("Should not have failed: %v", err)
|
||||
}
|
||||
if tt.isValid {
|
||||
diff := cmp.Diff(state, &tt.expected)
|
||||
diff := cmp.Diff(&tt.expected, state)
|
||||
if diff != "" {
|
||||
t.Fatalf("Data does not match: %s", diff)
|
||||
}
|
||||
|
|
@ -290,10 +290,10 @@ func TestMapFields(t *testing.T) {
|
|||
UserId: types.Int64Value(int64(1)),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringNull(),
|
||||
Name: types.StringValue(""),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
Status: types.StringValue(""),
|
||||
//ConnectionString: types.StringNull(),
|
||||
},
|
||||
true,
|
||||
|
|
@ -326,7 +326,7 @@ func TestMapFields(t *testing.T) {
|
|||
),
|
||||
),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
Status: types.StringValue(""),
|
||||
//ConnectionString: types.StringNull(),
|
||||
},
|
||||
true,
|
||||
|
|
@ -343,10 +343,10 @@ func TestMapFields(t *testing.T) {
|
|||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringNull(),
|
||||
Name: types.StringValue(""),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
Status: types.StringValue(""),
|
||||
//ConnectionString: types.StringNull(),
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||
|
||||
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
|
||||
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -38,7 +38,7 @@ func TestConfigureClient(t *testing.T) {
|
|||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
expected *postgresflex.APIClient
|
||||
expected *v3alpha1api.APIClient
|
||||
}{
|
||||
{
|
||||
name: "default endpoint",
|
||||
|
|
@ -47,8 +47,8 @@ func TestConfigureClient(t *testing.T) {
|
|||
Version: testVersion,
|
||||
},
|
||||
},
|
||||
expected: func() *postgresflex.APIClient {
|
||||
apiClient, err := postgresflex.NewAPIClient(
|
||||
expected: func() *v3alpha1api.APIClient {
|
||||
apiClient, err := v3alpha1api.NewAPIClient(
|
||||
config.WithRegion("eu01"),
|
||||
utils.UserAgentConfigOption(testVersion),
|
||||
)
|
||||
|
|
@ -67,8 +67,8 @@ func TestConfigureClient(t *testing.T) {
|
|||
PostgresFlexCustomEndpoint: testCustomEndpoint,
|
||||
},
|
||||
},
|
||||
expected: func() *postgresflex.APIClient {
|
||||
apiClient, err := postgresflex.NewAPIClient(
|
||||
expected: func() *v3alpha1api.APIClient {
|
||||
apiClient, err := v3alpha1api.NewAPIClient(
|
||||
utils.UserAgentConfigOption(testVersion),
|
||||
config.WithEndpoint(testCustomEndpoint),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue