feat(iaas): set custom user-agent header for STACKIT API calls (#821)
relates to STACKITTPR-184
This commit is contained in:
parent
536d824e5d
commit
53ec994a7d
39 changed files with 575 additions and 740 deletions
|
|
@ -5,6 +5,9 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
|
|
@ -217,3 +220,87 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseProviderData(t *testing.T) {
|
||||
type args struct {
|
||||
providerData any
|
||||
}
|
||||
type want struct {
|
||||
ok bool
|
||||
providerData core.ProviderData
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want want
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "provider has not been configured",
|
||||
args: args{
|
||||
providerData: nil,
|
||||
},
|
||||
want: want{
|
||||
ok: false,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "invalid provider data",
|
||||
args: args{
|
||||
providerData: struct{}{},
|
||||
},
|
||||
want: want{
|
||||
ok: false,
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "valid provider data 1",
|
||||
args: args{
|
||||
providerData: core.ProviderData{},
|
||||
},
|
||||
want: want{
|
||||
ok: true,
|
||||
providerData: core.ProviderData{},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "valid provider data 2",
|
||||
args: args{
|
||||
providerData: core.ProviderData{
|
||||
DefaultRegion: "eu02",
|
||||
RabbitMQCustomEndpoint: "https://rabbitmq-custom-endpoint.api.stackit.cloud",
|
||||
Version: "1.2.3",
|
||||
},
|
||||
},
|
||||
want: want{
|
||||
ok: true,
|
||||
providerData: core.ProviderData{
|
||||
DefaultRegion: "eu02",
|
||||
RabbitMQCustomEndpoint: "https://rabbitmq-custom-endpoint.api.stackit.cloud",
|
||||
Version: "1.2.3",
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
actual, ok := ParseProviderData(ctx, tt.args.providerData, &diags)
|
||||
if diags.HasError() != tt.wantErr {
|
||||
t.Errorf("ConfigureClient() error = %v, want %v", diags.HasError(), tt.wantErr)
|
||||
}
|
||||
if ok != tt.want.ok {
|
||||
t.Errorf("ParseProviderData() got = %v, want %v", ok, tt.want.ok)
|
||||
}
|
||||
if !reflect.DeepEqual(actual, tt.want.providerData) {
|
||||
t.Errorf("ParseProviderData() got = %v, want %v", actual, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue