835 lines
28 KiB
Go
835 lines
28 KiB
Go
/*
|
|
STACKIT Git API
|
|
|
|
Testing DefaultApiService
|
|
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
|
|
|
|
package gitbeta
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"net/url"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
|
)
|
|
|
|
func Test_gitbeta_DefaultApiService(t *testing.T) {
|
|
|
|
t.Run("Test DefaultApiService CreateAuthentication", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}/authentications"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Authentication{}
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
createAuthenticationPayload := CreateAuthenticationPayload{}
|
|
|
|
resp, reqErr := apiClient.CreateAuthentication(context.Background(), projectId, instanceId).CreateAuthenticationPayload(createAuthenticationPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService CreateInstance", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Instance{}
|
|
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 gitbeta_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
|
|
createInstancePayload := CreateInstancePayload{}
|
|
|
|
resp, reqErr := apiClient.CreateInstance(context.Background(), projectId).CreateInstancePayload(createInstancePayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService CreateRunner", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}/runner"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Runner{}
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
createRunnerPayload := CreateRunnerPayload{}
|
|
|
|
resp, reqErr := apiClient.CreateRunner(context.Background(), projectId, instanceId).CreateRunnerPayload(createRunnerPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteAuthentication", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}/authentications/{authenticationId}"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
authenticationIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"authenticationId"+"}", url.PathEscape(ParameterValueToString(authenticationIdValue, "authenticationId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
authenticationId := authenticationIdValue
|
|
|
|
reqErr := apiClient.DeleteAuthentication(context.Background(), projectId, instanceId, authenticationId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteInstance", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
|
|
reqErr := apiClient.DeleteInstance(context.Background(), projectId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteRunner", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}/runner"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
|
|
reqErr := apiClient.DeleteRunner(context.Background(), projectId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetAuthentication", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}/authentications/{authenticationId}"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
authenticationIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"authenticationId"+"}", url.PathEscape(ParameterValueToString(authenticationIdValue, "authenticationId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Authentication{}
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
authenticationId := authenticationIdValue
|
|
|
|
resp, reqErr := apiClient.GetAuthentication(context.Background(), projectId, instanceId, authenticationId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetInstance", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Instance{}
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
|
|
resp, reqErr := apiClient.GetInstance(context.Background(), projectId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetInstances", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := InstanceList{}
|
|
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 gitbeta_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
|
|
|
|
resp, reqErr := apiClient.GetInstances(context.Background(), projectId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetRunner", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}/runner"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Runner{}
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
|
|
resp, reqErr := apiClient.GetRunner(context.Background(), projectId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListAuthentication", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}/authentications"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := AuthenticationList{}
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
|
|
resp, reqErr := apiClient.ListAuthentication(context.Background(), projectId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListFlavors", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/flavors"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := FlavorsList{}
|
|
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 gitbeta_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
|
|
|
|
resp, reqErr := apiClient.ListFlavors(context.Background(), projectId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListRunnerRuntimes", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/runner-runtimes"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := RunnerRuntimeList{}
|
|
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 gitbeta_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
|
|
|
|
resp, reqErr := apiClient.ListRunnerRuntimes(context.Background(), projectId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService PatchAuthentication", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}/authentications/{authenticationId}"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
authenticationIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"authenticationId"+"}", url.PathEscape(ParameterValueToString(authenticationIdValue, "authenticationId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Authentication{}
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
authenticationId := authenticationIdValue
|
|
patchAuthenticationPayload := PatchAuthenticationPayload{}
|
|
|
|
resp, reqErr := apiClient.PatchAuthentication(context.Background(), projectId, instanceId, authenticationId).PatchAuthenticationPayload(patchAuthenticationPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService PatchInstance", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/instances/{instanceId}"
|
|
projectIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
instanceIdValue := randString(36)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Instance{}
|
|
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 gitbeta_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
|
|
instanceId := instanceIdValue
|
|
patchInstancePayload := PatchInstancePayload{}
|
|
|
|
resp, reqErr := apiClient.PatchInstance(context.Background(), projectId, instanceId).PatchInstancePayload(patchInstancePayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
}
|