fix: builder and sdk changes (#81)
## 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)
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-authored-by: marcel.henselin <marcel.henselin@stackit.cloud>
Reviewed-on: #81
This commit is contained in:
parent
635a9abf20
commit
1033d7e034
145 changed files with 5944 additions and 5298 deletions
|
|
@ -3,22 +3,16 @@ package stackit_test
|
|||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
test "github.com/hashicorp/terraform-plugin-testing/helper/resource" //nolint:staticcheck // used for acceptance testing
|
||||
"github.com/jarcoal/httpmock"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/clients"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
|
||||
sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database"
|
||||
|
||||
//nolint:staticcheck // used for acceptance testing
|
||||
postgresFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavor"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
||||
|
|
@ -29,12 +23,9 @@ import (
|
|||
postgresflexalphaFlavors "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors"
|
||||
postgresFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance"
|
||||
postgresFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user"
|
||||
sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database"
|
||||
sqlserverFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavor"
|
||||
sqlserverFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance"
|
||||
sqlserverFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user"
|
||||
sqlserverflexBetaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database"
|
||||
sqlserverFlexBetaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/flavor"
|
||||
sqlserverFlexBetaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance"
|
||||
sqlserverFlexBetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user"
|
||||
|
||||
|
|
@ -62,106 +53,6 @@ func TestMain(m *testing.M) {
|
|||
os.Exit(code)
|
||||
}
|
||||
|
||||
func TestMshTest(t *testing.T) {
|
||||
httpmock.Activate()
|
||||
defer httpmock.DeactivateAndReset()
|
||||
|
||||
testutils.ActivateEnvironmentHttpMocks()
|
||||
|
||||
httpmock.RegisterResponder(
|
||||
"POST", `https://service-account.api.stackit.cloud/token`,
|
||||
func(_ *http.Request) (*http.Response, error) {
|
||||
token := jwt.NewWithClaims(
|
||||
jwt.SigningMethodHS256, jwt.MapClaims{
|
||||
"foo": "bar",
|
||||
"nbf": time.Date(2015, 10, 10, 12, 0, 0, 0, time.UTC).Unix(),
|
||||
},
|
||||
)
|
||||
// Sign and get the complete encoded token as a string using the secret
|
||||
tokenString, err := token.SignedString([]byte("mySecret"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
tR := clients.TokenResponseBody{
|
||||
AccessToken: tokenString,
|
||||
ExpiresIn: 3600,
|
||||
RefreshToken: "",
|
||||
Scope: "",
|
||||
TokenType: "",
|
||||
}
|
||||
|
||||
return httpmock.NewJsonResponse(http.StatusOK, tR)
|
||||
},
|
||||
)
|
||||
|
||||
httpmock.RegisterResponder(
|
||||
"GET",
|
||||
`https://postgres-flex-service.api.eu01.stackit.cloud/v3alpha1/projects/xyz-project-id/regions/eu01/flavors?page=1&size=25&sort=id.asc`,
|
||||
func(_ *http.Request) (*http.Response, error) {
|
||||
res := postgresflexalpha.GetFlavorsResponse{
|
||||
Flavors: &[]postgresflexalpha.ListFlavors{
|
||||
{
|
||||
Cpu: nil,
|
||||
Description: nil,
|
||||
Id: nil,
|
||||
MaxGB: nil,
|
||||
Memory: nil,
|
||||
MinGB: nil,
|
||||
NodeType: nil,
|
||||
StorageClasses: nil,
|
||||
},
|
||||
},
|
||||
Pagination: &postgresflexalpha.Pagination{
|
||||
Page: utils.Ptr(int64(1)),
|
||||
Size: utils.Ptr(int64(25)),
|
||||
Sort: nil,
|
||||
TotalPages: utils.Ptr(int64(1)),
|
||||
TotalRows: utils.Ptr(int64(0)),
|
||||
},
|
||||
}
|
||||
return httpmock.NewJsonResponse(
|
||||
http.StatusOK,
|
||||
res,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
test.Test(
|
||||
t, test.TestCase{
|
||||
IsUnitTest: true,
|
||||
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
|
||||
Steps: []test.TestStep{
|
||||
{
|
||||
ConfigVariables: map[string]config.Variable{
|
||||
"project_id": config.StringVariable("xyz-project-id"),
|
||||
},
|
||||
Config: fmt.Sprintf(
|
||||
`
|
||||
provider "stackitprivatepreview" {
|
||||
default_region = "%[1]s"
|
||||
service_account_key_path = "%[2]s"
|
||||
}
|
||||
variable "project_id" {
|
||||
type = string
|
||||
}
|
||||
data "stackitprivatepreview_postgresflexalpha_flavor" "all" {
|
||||
project_id = var.project_id
|
||||
region = "eu01"
|
||||
cpu = 2
|
||||
ram = 4
|
||||
node_type = "Single"
|
||||
storage_class = "premium-perf2-stackit"
|
||||
}`,
|
||||
os.Getenv("TF_ACC_REGION"),
|
||||
os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"),
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func TestUnitProviderHasChildDataSources_Basic(t *testing.T) {
|
||||
expectedDataSources := []datasource.DataSource{
|
||||
postgresFlexAlphaFlavor.NewFlavorDataSource(),
|
||||
|
|
@ -171,7 +62,7 @@ func TestUnitProviderHasChildDataSources_Basic(t *testing.T) {
|
|||
postgresFlexAlphaUser.NewUserDataSource(),
|
||||
postgresflexalphaFlavors.NewFlavorsDataSource(),
|
||||
|
||||
sqlserverFlexAlphaFlavor.NewFlavorDataSource(),
|
||||
// sqlserverFlexAlphaFlavor.NewFlavorDataSource(),
|
||||
sqlserverFlexAlphaInstance.NewInstanceDataSource(),
|
||||
sqlserverFlexAlphaUser.NewUserDataSource(),
|
||||
sqlserverflexalphaDatabase.NewDatabaseDataSource(),
|
||||
|
|
@ -179,7 +70,7 @@ func TestUnitProviderHasChildDataSources_Basic(t *testing.T) {
|
|||
sqlserverflexBetaDatabase.NewDatabaseDataSource(),
|
||||
sqlserverFlexBetaInstance.NewInstanceDataSource(),
|
||||
sqlserverFlexBetaUser.NewUserDataSource(),
|
||||
sqlserverFlexBetaFlavor.NewFlavorDataSource(),
|
||||
// sqlserverFlexBetaFlavor.NewFlavorDataSource(),
|
||||
}
|
||||
provider, ok := stackit.New("testing")().(*stackit.Provider)
|
||||
if !ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue