feat: auto generated files and new structure (#4)
## 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)
Reviewed-on: #4
Reviewed-by: Andre_Harms <andre.harms@stackit.cloud>
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
This commit is contained in:
parent
979220be66
commit
9f41c4da7f
1283 changed files with 273211 additions and 4614 deletions
312
pkg/runcommandbeta/api_default_test.go
Normal file
312
pkg/runcommandbeta/api_default_test.go
Normal file
|
|
@ -0,0 +1,312 @@
|
|||
/*
|
||||
STACKIT Run Commands Service API
|
||||
|
||||
Testing DefaultApiService
|
||||
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
|
||||
|
||||
package runcommandbeta
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
||||
)
|
||||
|
||||
func Test_runcommandbeta_DefaultApiService(t *testing.T) {
|
||||
|
||||
t.Run("Test DefaultApiService CreateCommand", func(t *testing.T) {
|
||||
_apiUrlPath := "/v2beta/projects/{projectId}/regions/{region}/servers/{serverId}/commands"
|
||||
projectIdValue := "projectId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
||||
serverIdValue := "serverId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(serverIdValue, "serverId")), -1)
|
||||
regionValue := "region-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
|
||||
|
||||
testDefaultApiServeMux := http.NewServeMux()
|
||||
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
||||
data := NewCommandResponse{}
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(data)
|
||||
})
|
||||
testServer := httptest.NewServer(testDefaultApiServeMux)
|
||||
defer testServer.Close()
|
||||
|
||||
configuration := &config.Configuration{
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
||||
Debug: false,
|
||||
Region: "test_region",
|
||||
Servers: config.ServerConfigurations{
|
||||
{
|
||||
URL: testServer.URL,
|
||||
Description: "Localhost for runcommandbeta_DefaultApi",
|
||||
Variables: map[string]config.ServerVariable{
|
||||
"region": {
|
||||
DefaultValue: "test_region.",
|
||||
EnumValues: []string{
|
||||
"test_region.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
OperationServers: map[string]config.ServerConfigurations{},
|
||||
}
|
||||
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
||||
if err != nil {
|
||||
t.Fatalf("creating API client: %v", err)
|
||||
}
|
||||
|
||||
projectId := projectIdValue
|
||||
serverId := serverIdValue
|
||||
region := regionValue
|
||||
|
||||
resp, reqErr := apiClient.CreateCommand(context.Background(), projectId, serverId, region).Execute()
|
||||
|
||||
if reqErr != nil {
|
||||
t.Fatalf("error in call: %v", reqErr)
|
||||
}
|
||||
if IsNil(resp) {
|
||||
t.Fatalf("response not present")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Test DefaultApiService GetCommand", func(t *testing.T) {
|
||||
_apiUrlPath := "/v2beta/projects/{projectId}/regions/{region}/servers/{serverId}/commands/{commandId}"
|
||||
projectIdValue := "projectId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
||||
regionValue := "region-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
|
||||
serverIdValue := "serverId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(serverIdValue, "serverId")), -1)
|
||||
commandIdValue := "commandId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"commandId"+"}", url.PathEscape(ParameterValueToString(commandIdValue, "commandId")), -1)
|
||||
|
||||
testDefaultApiServeMux := http.NewServeMux()
|
||||
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
||||
data := CommandDetails{}
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(data)
|
||||
})
|
||||
testServer := httptest.NewServer(testDefaultApiServeMux)
|
||||
defer testServer.Close()
|
||||
|
||||
configuration := &config.Configuration{
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
||||
Debug: false,
|
||||
Region: "test_region",
|
||||
Servers: config.ServerConfigurations{
|
||||
{
|
||||
URL: testServer.URL,
|
||||
Description: "Localhost for runcommandbeta_DefaultApi",
|
||||
Variables: map[string]config.ServerVariable{
|
||||
"region": {
|
||||
DefaultValue: "test_region.",
|
||||
EnumValues: []string{
|
||||
"test_region.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
OperationServers: map[string]config.ServerConfigurations{},
|
||||
}
|
||||
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
||||
if err != nil {
|
||||
t.Fatalf("creating API client: %v", err)
|
||||
}
|
||||
|
||||
projectId := projectIdValue
|
||||
region := regionValue
|
||||
serverId := serverIdValue
|
||||
commandId := commandIdValue
|
||||
|
||||
resp, reqErr := apiClient.GetCommand(context.Background(), projectId, region, serverId, commandId).Execute()
|
||||
|
||||
if reqErr != nil {
|
||||
t.Fatalf("error in call: %v", reqErr)
|
||||
}
|
||||
if IsNil(resp) {
|
||||
t.Fatalf("response not present")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Test DefaultApiService GetCommandTemplate", func(t *testing.T) {
|
||||
_apiUrlPath := "/v2beta/projects/{projectId}/regions/{region}/servers/{serverId}/command-templates/{commandTemplateName}"
|
||||
projectIdValue := "projectId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
||||
serverIdValue := "serverId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(serverIdValue, "serverId")), -1)
|
||||
commandTemplateNameValue := "commandTemplateName-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"commandTemplateName"+"}", url.PathEscape(ParameterValueToString(commandTemplateNameValue, "commandTemplateName")), -1)
|
||||
regionValue := "region-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
|
||||
|
||||
testDefaultApiServeMux := http.NewServeMux()
|
||||
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
||||
data := CommandTemplateSchema{}
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(data)
|
||||
})
|
||||
testServer := httptest.NewServer(testDefaultApiServeMux)
|
||||
defer testServer.Close()
|
||||
|
||||
configuration := &config.Configuration{
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
||||
Debug: false,
|
||||
Region: "test_region",
|
||||
Servers: config.ServerConfigurations{
|
||||
{
|
||||
URL: testServer.URL,
|
||||
Description: "Localhost for runcommandbeta_DefaultApi",
|
||||
Variables: map[string]config.ServerVariable{
|
||||
"region": {
|
||||
DefaultValue: "test_region.",
|
||||
EnumValues: []string{
|
||||
"test_region.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
OperationServers: map[string]config.ServerConfigurations{},
|
||||
}
|
||||
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
||||
if err != nil {
|
||||
t.Fatalf("creating API client: %v", err)
|
||||
}
|
||||
|
||||
projectId := projectIdValue
|
||||
serverId := serverIdValue
|
||||
commandTemplateName := commandTemplateNameValue
|
||||
region := regionValue
|
||||
|
||||
resp, reqErr := apiClient.GetCommandTemplate(context.Background(), projectId, serverId, commandTemplateName, region).Execute()
|
||||
|
||||
if reqErr != nil {
|
||||
t.Fatalf("error in call: %v", reqErr)
|
||||
}
|
||||
if IsNil(resp) {
|
||||
t.Fatalf("response not present")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Test DefaultApiService ListCommandTemplates", func(t *testing.T) {
|
||||
_apiUrlPath := "/v2beta/command-templates"
|
||||
|
||||
testDefaultApiServeMux := http.NewServeMux()
|
||||
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
||||
data := CommandTemplateResponse{}
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(data)
|
||||
})
|
||||
testServer := httptest.NewServer(testDefaultApiServeMux)
|
||||
defer testServer.Close()
|
||||
|
||||
configuration := &config.Configuration{
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
||||
Debug: false,
|
||||
Region: "test_region",
|
||||
Servers: config.ServerConfigurations{
|
||||
{
|
||||
URL: testServer.URL,
|
||||
Description: "Localhost for runcommandbeta_DefaultApi",
|
||||
Variables: map[string]config.ServerVariable{
|
||||
"region": {
|
||||
DefaultValue: "test_region.",
|
||||
EnumValues: []string{
|
||||
"test_region.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
OperationServers: map[string]config.ServerConfigurations{},
|
||||
}
|
||||
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
||||
if err != nil {
|
||||
t.Fatalf("creating API client: %v", err)
|
||||
}
|
||||
|
||||
resp, reqErr := apiClient.ListCommandTemplates(context.Background()).Execute()
|
||||
|
||||
if reqErr != nil {
|
||||
t.Fatalf("error in call: %v", reqErr)
|
||||
}
|
||||
if IsNil(resp) {
|
||||
t.Fatalf("response not present")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Test DefaultApiService ListCommands", func(t *testing.T) {
|
||||
_apiUrlPath := "/v2beta/projects/{projectId}/regions/{region}/servers/{serverId}/commands"
|
||||
projectIdValue := "projectId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
||||
serverIdValue := "serverId-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(serverIdValue, "serverId")), -1)
|
||||
regionValue := "region-value"
|
||||
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
|
||||
|
||||
testDefaultApiServeMux := http.NewServeMux()
|
||||
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
||||
data := GetCommandsResponse{}
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(data)
|
||||
})
|
||||
testServer := httptest.NewServer(testDefaultApiServeMux)
|
||||
defer testServer.Close()
|
||||
|
||||
configuration := &config.Configuration{
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
||||
Debug: false,
|
||||
Region: "test_region",
|
||||
Servers: config.ServerConfigurations{
|
||||
{
|
||||
URL: testServer.URL,
|
||||
Description: "Localhost for runcommandbeta_DefaultApi",
|
||||
Variables: map[string]config.ServerVariable{
|
||||
"region": {
|
||||
DefaultValue: "test_region.",
|
||||
EnumValues: []string{
|
||||
"test_region.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
OperationServers: map[string]config.ServerConfigurations{},
|
||||
}
|
||||
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
||||
if err != nil {
|
||||
t.Fatalf("creating API client: %v", err)
|
||||
}
|
||||
|
||||
projectId := projectIdValue
|
||||
serverId := serverIdValue
|
||||
region := regionValue
|
||||
|
||||
resp, reqErr := apiClient.ListCommands(context.Background(), projectId, serverId, region).Execute()
|
||||
|
||||
if reqErr != nil {
|
||||
t.Fatalf("error in call: %v", reqErr)
|
||||
}
|
||||
if IsNil(resp) {
|
||||
t.Fatalf("response not present")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue