feat: initial copy of v0.1.0
This commit is contained in:
parent
4cc801a7f3
commit
7d4cbb6b08
538 changed files with 63361 additions and 55213 deletions
|
|
@ -0,0 +1,191 @@
|
|||
package postgresflexalpha
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
|
||||
postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
|
||||
|
||||
postgresflexalpharesource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/resources_gen"
|
||||
utils2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||
)
|
||||
|
||||
func Test_handleConnectionInfo(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
m *dataSourceModel
|
||||
hostName string
|
||||
port int32
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
}{
|
||||
{
|
||||
name: "empty connection info",
|
||||
args: args{
|
||||
ctx: context.TODO(),
|
||||
m: &dataSourceModel{},
|
||||
hostName: "",
|
||||
port: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty connection info host",
|
||||
args: args{
|
||||
ctx: context.TODO(),
|
||||
m: &dataSourceModel{},
|
||||
hostName: "",
|
||||
port: 1234,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty connection info port",
|
||||
args: args{
|
||||
ctx: context.TODO(),
|
||||
m: &dataSourceModel{},
|
||||
hostName: "hostname",
|
||||
port: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid connection info",
|
||||
args: args{
|
||||
ctx: context.TODO(),
|
||||
m: &dataSourceModel{},
|
||||
hostName: "host",
|
||||
port: 1000,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
resp := &postgresflex.GetInstanceResponse{
|
||||
ConnectionInfo: postgresflex.InstanceConnectionInfo{
|
||||
Write: postgresflex.InstanceConnectionInfoWrite{
|
||||
Host: tt.args.hostName,
|
||||
Port: int32(tt.args.port),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
handleConnectionInfo(tt.args.ctx, tt.args.m, resp)
|
||||
|
||||
if tt.args.hostName == "" || tt.args.port == 0 {
|
||||
if !tt.args.m.ConnectionInfo.IsNull() {
|
||||
t.Errorf("expected connection info to be null")
|
||||
}
|
||||
}
|
||||
|
||||
if tt.args.hostName != "" && tt.args.port != 0 {
|
||||
res := tt.args.m.ConnectionInfo.Write.Attributes()
|
||||
gotHost := ""
|
||||
if r, ok := res["host"]; ok {
|
||||
gotHost = utils2.RemoveQuotes(r.String())
|
||||
}
|
||||
if gotHost != tt.args.hostName {
|
||||
t.Errorf("host value incorrect: want: %s - got: %s", tt.args.hostName, gotHost)
|
||||
}
|
||||
|
||||
gotPort, ok := res["port"]
|
||||
if !ok {
|
||||
t.Errorf("could not find a value for port in connection_info.write")
|
||||
}
|
||||
if !gotPort.Equal(types.Int64Value(int64(tt.args.port))) {
|
||||
t.Errorf("port value incorrect: want: %d - got: %s", tt.args.port, gotPort.String())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_handleEncryption(t *testing.T) {
|
||||
t.Skipf("please implement")
|
||||
type args struct {
|
||||
m *dataSourceModel
|
||||
resp *postgresflex.GetInstanceResponse
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
handleEncryption(tt.args.m, tt.args.resp)
|
||||
t.Logf("need to implement more")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_handleNetwork(t *testing.T) {
|
||||
t.Skipf("please implement")
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
m *dataSourceModel
|
||||
resp *postgresflex.GetInstanceResponse
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := handleNetwork(tt.args.ctx, tt.args.m, tt.args.resp); (err != nil) != tt.wantErr {
|
||||
t.Errorf("handleNetwork() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_mapGetDataInstanceResponseToModel(t *testing.T) {
|
||||
t.Skipf("please implement")
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
m *dataSourceModel
|
||||
resp *postgresflex.GetInstanceResponse
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := mapGetDataInstanceResponseToModel(tt.args.ctx, tt.args.m, tt.args.resp); (err != nil) != tt.wantErr {
|
||||
t.Errorf("mapGetDataInstanceResponseToModel() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_mapGetInstanceResponseToModel(t *testing.T) {
|
||||
t.Skipf("please implement")
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
m *postgresflexalpharesource.InstanceModel
|
||||
resp *postgresflex.GetInstanceResponse
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := mapGetInstanceResponseToModel(tt.args.ctx, tt.args.m, tt.args.resp); (err != nil) != tt.wantErr {
|
||||
t.Errorf("mapGetInstanceResponseToModel() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue