From fdf8fce5f4ad9a903b84d77ffd45306fc65b6444 Mon Sep 17 00:00:00 2001 From: Afreen1998 Date: Thu, 28 Nov 2024 13:31:01 +0530 Subject: [PATCH] feat(IBM Cloud Shell): re-gen service for adopting the new error toolchain Signed-off-by: Afreen1998 --- ibmcloudshellv1/ibm_cloud_shell_v1.go | 84 ++++- .../ibm_cloud_shell_v1_examples_test.go | 4 - .../ibm_cloud_shell_v1_integration_test.go | 4 - .../ibm_cloud_shell_v1_suite_test.go | 2 +- ibmcloudshellv1/ibm_cloud_shell_v1_test.go | 355 +++++++++--------- 5 files changed, 243 insertions(+), 206 deletions(-) diff --git a/ibmcloudshellv1/ibm_cloud_shell_v1.go b/ibmcloudshellv1/ibm_cloud_shell_v1.go index dad013ef..a2189375 100644 --- a/ibmcloudshellv1/ibm_cloud_shell_v1.go +++ b/ibmcloudshellv1/ibm_cloud_shell_v1.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.33.0-caf29bd0-20210603-225214 + * IBM OpenAPI SDK Code Generator Version: 3.96.1-5136e54a-20241108-203028 */ // Package ibmcloudshellv1 : Operations and models for the IBMCloudShellV1 service @@ -24,7 +24,6 @@ package ibmcloudshellv1 import ( "context" "encoding/json" - "fmt" "net/http" "reflect" "time" @@ -35,7 +34,7 @@ import ( // IBMCloudShellV1 : API docs for IBM Cloud Shell repository // -// Version: 1.0 +// API Version: 1.0 type IBMCloudShellV1 struct { Service *core.BaseService } @@ -62,22 +61,26 @@ func NewIBMCloudShellV1UsingExternalConfig(options *IBMCloudShellV1Options) (ibm if options.Authenticator == nil { options.Authenticator, err = core.GetAuthenticatorFromEnvironment(options.ServiceName) if err != nil { + err = core.SDKErrorf(err, "", "env-auth-error", common.GetComponentInfo()) return } } ibmCloudShell, err = NewIBMCloudShellV1(options) + err = core.RepurposeSDKProblem(err, "new-client-error") if err != nil { return } err = ibmCloudShell.Service.ConfigureService(options.ServiceName) if err != nil { + err = core.SDKErrorf(err, "", "client-config-error", common.GetComponentInfo()) return } if options.URL != "" { err = ibmCloudShell.Service.SetServiceURL(options.URL) + err = core.RepurposeSDKProblem(err, "url-set-error") } return } @@ -91,12 +94,14 @@ func NewIBMCloudShellV1(options *IBMCloudShellV1Options) (service *IBMCloudShell baseService, err := core.NewBaseService(serviceOptions) if err != nil { + err = core.SDKErrorf(err, "", "new-base-error", common.GetComponentInfo()) return } if options.URL != "" { err = baseService.SetServiceURL(options.URL) if err != nil { + err = core.SDKErrorf(err, "", "set-url-error", common.GetComponentInfo()) return } } @@ -110,7 +115,7 @@ func NewIBMCloudShellV1(options *IBMCloudShellV1Options) (service *IBMCloudShell // GetServiceURLForRegion returns the service URL to be used for the specified region func GetServiceURLForRegion(region string) (string, error) { - return "", fmt.Errorf("service does not support regional URLs") + return "", core.SDKErrorf(nil, "service does not support regional URLs", "no-regional-support", common.GetComponentInfo()) } // Clone makes a copy of "ibmCloudShell" suitable for processing requests. @@ -125,7 +130,11 @@ func (ibmCloudShell *IBMCloudShellV1) Clone() *IBMCloudShellV1 { // SetServiceURL sets the service URL func (ibmCloudShell *IBMCloudShellV1) SetServiceURL(url string) error { - return ibmCloudShell.Service.SetServiceURL(url) + err := ibmCloudShell.Service.SetServiceURL(url) + if err != nil { + err = core.SDKErrorf(err, "", "url-set-error", common.GetComponentInfo()) + } + return err } // GetServiceURL returns the service URL @@ -165,17 +174,21 @@ func (ibmCloudShell *IBMCloudShellV1) DisableRetries() { // be an account owner or users need to be assigned an IAM policy with the Administrator role for the Cloud Shell // account management service. func (ibmCloudShell *IBMCloudShellV1) GetAccountSettings(getAccountSettingsOptions *GetAccountSettingsOptions) (result *AccountSettings, response *core.DetailedResponse, err error) { - return ibmCloudShell.GetAccountSettingsWithContext(context.Background(), getAccountSettingsOptions) + result, response, err = ibmCloudShell.GetAccountSettingsWithContext(context.Background(), getAccountSettingsOptions) + err = core.RepurposeSDKProblem(err, "") + return } // GetAccountSettingsWithContext is an alternate form of the GetAccountSettings method which supports a Context parameter func (ibmCloudShell *IBMCloudShellV1) GetAccountSettingsWithContext(ctx context.Context, getAccountSettingsOptions *GetAccountSettingsOptions) (result *AccountSettings, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getAccountSettingsOptions, "getAccountSettingsOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(getAccountSettingsOptions, "getAccountSettingsOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -188,6 +201,7 @@ func (ibmCloudShell *IBMCloudShellV1) GetAccountSettingsWithContext(ctx context. builder.EnableGzipCompression = ibmCloudShell.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(ibmCloudShell.Service.Options.URL, `/api/v1/user/accounts/{account_id}/settings`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -203,17 +217,21 @@ func (ibmCloudShell *IBMCloudShellV1) GetAccountSettingsWithContext(ctx context. request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = ibmCloudShell.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_account_settings", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettings) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -228,17 +246,21 @@ func (ibmCloudShell *IBMCloudShellV1) GetAccountSettingsWithContext(ctx context. // settings, users need to be an account owner or users need to be assigned an IAM policy with the Administrator role // for the Cloud Shell account management service. func (ibmCloudShell *IBMCloudShellV1) UpdateAccountSettings(updateAccountSettingsOptions *UpdateAccountSettingsOptions) (result *AccountSettings, response *core.DetailedResponse, err error) { - return ibmCloudShell.UpdateAccountSettingsWithContext(context.Background(), updateAccountSettingsOptions) + result, response, err = ibmCloudShell.UpdateAccountSettingsWithContext(context.Background(), updateAccountSettingsOptions) + err = core.RepurposeSDKProblem(err, "") + return } // UpdateAccountSettingsWithContext is an alternate form of the UpdateAccountSettings method which supports a Context parameter func (ibmCloudShell *IBMCloudShellV1) UpdateAccountSettingsWithContext(ctx context.Context, updateAccountSettingsOptions *UpdateAccountSettingsOptions) (result *AccountSettings, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(updateAccountSettingsOptions, "updateAccountSettingsOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(updateAccountSettingsOptions, "updateAccountSettingsOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -251,6 +273,7 @@ func (ibmCloudShell *IBMCloudShellV1) UpdateAccountSettingsWithContext(ctx conte builder.EnableGzipCompression = ibmCloudShell.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(ibmCloudShell.Service.Options.URL, `/api/v1/user/accounts/{account_id}/settings`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -286,22 +309,27 @@ func (ibmCloudShell *IBMCloudShellV1) UpdateAccountSettingsWithContext(ctx conte } _, err = builder.SetBodyContentJSON(body) if err != nil { + err = core.SDKErrorf(err, "", "set-json-body-error", common.GetComponentInfo()) return } request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = ibmCloudShell.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "update_account_settings", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettings) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -309,6 +337,9 @@ func (ibmCloudShell *IBMCloudShellV1) UpdateAccountSettingsWithContext(ctx conte return } +func getServiceComponentInfo() *core.ProblemComponent { + return core.NewProblemComponent(DefaultServiceName, "1.0") +} // AccountSettings : Definition of Cloud Shell account settings. type AccountSettings struct { @@ -359,54 +390,67 @@ func UnmarshalAccountSettings(m map[string]json.RawMessage, result interface{}) obj := new(AccountSettings) err = core.UnmarshalPrimitive(m, "_id", &obj.ID) if err != nil { + err = core.SDKErrorf(err, "", "_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "_rev", &obj.Rev) if err != nil { + err = core.SDKErrorf(err, "", "_rev-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { + err = core.SDKErrorf(err, "", "account_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { + err = core.SDKErrorf(err, "", "created_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_by", &obj.CreatedBy) if err != nil { + err = core.SDKErrorf(err, "", "created_by-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "default_enable_new_features", &obj.DefaultEnableNewFeatures) if err != nil { + err = core.SDKErrorf(err, "", "default_enable_new_features-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "default_enable_new_regions", &obj.DefaultEnableNewRegions) if err != nil { + err = core.SDKErrorf(err, "", "default_enable_new_regions-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "features", &obj.Features, UnmarshalFeature) if err != nil { + err = core.SDKErrorf(err, "", "features-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "regions", &obj.Regions, UnmarshalRegionSetting) if err != nil { + err = core.SDKErrorf(err, "", "regions-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { + err = core.SDKErrorf(err, "", "type-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "updated_at", &obj.UpdatedAt) if err != nil { + err = core.SDKErrorf(err, "", "updated_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "updated_by", &obj.UpdatedBy) if err != nil { + err = core.SDKErrorf(err, "", "updated_by-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -427,10 +471,12 @@ func UnmarshalFeature(m map[string]json.RawMessage, result interface{}) (err err obj := new(Feature) err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "key", &obj.Key) if err != nil { + err = core.SDKErrorf(err, "", "key-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -440,9 +486,9 @@ func UnmarshalFeature(m map[string]json.RawMessage, result interface{}) (err err // GetAccountSettingsOptions : The GetAccountSettings options. type GetAccountSettingsOptions struct { // The account ID in which the account settings belong to. - AccountID *string `validate:"required,ne="` + AccountID *string `json:"account_id" validate:"required,ne="` - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } @@ -479,10 +525,12 @@ func UnmarshalRegionSetting(m map[string]json.RawMessage, result interface{}) (e obj := new(RegionSetting) err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "key", &obj.Key) if err != nil { + err = core.SDKErrorf(err, "", "key-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -492,29 +540,29 @@ func UnmarshalRegionSetting(m map[string]json.RawMessage, result interface{}) (e // UpdateAccountSettingsOptions : The UpdateAccountSettings options. type UpdateAccountSettingsOptions struct { // The account ID in which the account settings belong to. - AccountID *string `validate:"required,ne="` + AccountID *string `json:"account_id" validate:"required,ne="` // Unique revision number for the settings object. - Rev *string + Rev *string `json:"_rev,omitempty"` // You can choose which Cloud Shell features are available in the account and whether any new features are enabled as // they become available. The feature settings apply only to the enabled Cloud Shell locations. - DefaultEnableNewFeatures *bool + DefaultEnableNewFeatures *bool `json:"default_enable_new_features,omitempty"` // Set whether Cloud Shell is enabled in a specific location for the account. The location determines where user and // session data are stored. By default, users are routed to the nearest available location. - DefaultEnableNewRegions *bool + DefaultEnableNewRegions *bool `json:"default_enable_new_regions,omitempty"` // When enabled, Cloud Shell is available to all users in the account. - Enabled *bool + Enabled *bool `json:"enabled,omitempty"` // List of Cloud Shell features. - Features []Feature + Features []Feature `json:"features,omitempty"` // List of Cloud Shell region settings. - Regions []RegionSetting + Regions []RegionSetting `json:"regions,omitempty"` - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } diff --git a/ibmcloudshellv1/ibm_cloud_shell_v1_examples_test.go b/ibmcloudshellv1/ibm_cloud_shell_v1_examples_test.go index 4b1a7fac..6b40e186 100644 --- a/ibmcloudshellv1/ibm_cloud_shell_v1_examples_test.go +++ b/ibmcloudshellv1/ibm_cloud_shell_v1_examples_test.go @@ -148,10 +148,6 @@ var _ = Describe(`IBMCloudShellV1 Examples Tests`, func() { Enabled: core.BoolPtr(true), Key: core.StringPtr("eu-de"), }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("jp-tok"), - }, { Enabled: core.BoolPtr(true), Key: core.StringPtr("us-south"), diff --git a/ibmcloudshellv1/ibm_cloud_shell_v1_integration_test.go b/ibmcloudshellv1/ibm_cloud_shell_v1_integration_test.go index 38b26714..8bd05036 100644 --- a/ibmcloudshellv1/ibm_cloud_shell_v1_integration_test.go +++ b/ibmcloudshellv1/ibm_cloud_shell_v1_integration_test.go @@ -152,10 +152,6 @@ var _ = Describe(`IBMCloudShellV1 Integration Tests`, func() { Enabled: core.BoolPtr(true), Key: core.StringPtr("eu-de"), }, - { - Enabled: core.BoolPtr(false), - Key: core.StringPtr("jp-tok"), - }, { Enabled: core.BoolPtr(false), Key: core.StringPtr("us-south"), diff --git a/ibmcloudshellv1/ibm_cloud_shell_v1_suite_test.go b/ibmcloudshellv1/ibm_cloud_shell_v1_suite_test.go index 0c0cf3c2..bb607ae7 100644 --- a/ibmcloudshellv1/ibm_cloud_shell_v1_suite_test.go +++ b/ibmcloudshellv1/ibm_cloud_shell_v1_suite_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ibmcloudshellv1/ibm_cloud_shell_v1_test.go b/ibmcloudshellv1/ibm_cloud_shell_v1_test.go index 0b4f27c9..05fec453 100644 --- a/ibmcloudshellv1/ibm_cloud_shell_v1_test.go +++ b/ibmcloudshellv1/ibm_cloud_shell_v1_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ package ibmcloudshellv1_test import ( "bytes" "context" + "encoding/base64" + "encoding/json" "fmt" "io" "net/http" @@ -66,13 +68,14 @@ var _ = Describe(`IBMCloudShellV1`, func() { Context(`Using external config, construct service client instances`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IBM_CLOUD_SHELL_URL": "https://ibmcloudshellv1/api", + "IBM_CLOUD_SHELL_URL": "https://ibmcloudshellv1/api", "IBM_CLOUD_SHELL_AUTH_TYPE": "noauth", } It(`Create service client using external config successfully`, func() { SetTestEnvironment(testEnvironment) - ibmCloudShellService, serviceErr := ibmcloudshellv1.NewIBMCloudShellV1UsingExternalConfig(&ibmcloudshellv1.IBMCloudShellV1Options{}) + ibmCloudShellService, serviceErr := ibmcloudshellv1.NewIBMCloudShellV1UsingExternalConfig(&ibmcloudshellv1.IBMCloudShellV1Options{ + }) Expect(ibmCloudShellService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) ClearTestEnvironment(testEnvironment) @@ -101,7 +104,8 @@ var _ = Describe(`IBMCloudShellV1`, func() { }) It(`Create service client using external config and set url programatically successfully`, func() { SetTestEnvironment(testEnvironment) - ibmCloudShellService, serviceErr := ibmcloudshellv1.NewIBMCloudShellV1UsingExternalConfig(&ibmcloudshellv1.IBMCloudShellV1Options{}) + ibmCloudShellService, serviceErr := ibmcloudshellv1.NewIBMCloudShellV1UsingExternalConfig(&ibmcloudshellv1.IBMCloudShellV1Options{ + }) err := ibmCloudShellService.SetServiceURL("https://testService/api") Expect(err).To(BeNil()) Expect(ibmCloudShellService).ToNot(BeNil()) @@ -119,12 +123,13 @@ var _ = Describe(`IBMCloudShellV1`, func() { Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IBM_CLOUD_SHELL_URL": "https://ibmcloudshellv1/api", + "IBM_CLOUD_SHELL_URL": "https://ibmcloudshellv1/api", "IBM_CLOUD_SHELL_AUTH_TYPE": "someOtherAuth", } SetTestEnvironment(testEnvironment) - ibmCloudShellService, serviceErr := ibmcloudshellv1.NewIBMCloudShellV1UsingExternalConfig(&ibmcloudshellv1.IBMCloudShellV1Options{}) + ibmCloudShellService, serviceErr := ibmcloudshellv1.NewIBMCloudShellV1UsingExternalConfig(&ibmcloudshellv1.IBMCloudShellV1Options{ + }) It(`Instantiate service client with error`, func() { Expect(ibmCloudShellService).To(BeNil()) @@ -135,7 +140,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { Context(`Using external config, construct service client instances with error: Invalid URL`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IBM_CLOUD_SHELL_AUTH_TYPE": "NOAuth", + "IBM_CLOUD_SHELL_AUTH_TYPE": "NOAuth", } SetTestEnvironment(testEnvironment) @@ -161,7 +166,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { }) }) Describe(`GetAccountSettings(getAccountSettingsOptions *GetAccountSettingsOptions) - Operation response error`, func() { - getAccountSettingsPath := "/api/v1/user/accounts/12345678-abcd-1a2b-a1b2-1234567890ab/settings" + getAccountSettingsPath := "/api/v1/user/accounts/testString/settings" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { @@ -172,7 +177,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke GetAccountSettings with error: Operation response processing error`, func() { @@ -185,7 +190,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { // Construct an instance of the GetAccountSettingsOptions model getAccountSettingsOptionsModel := new(ibmcloudshellv1.GetAccountSettingsOptions) - getAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") + getAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") getAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := ibmCloudShellService.GetAccountSettings(getAccountSettingsOptionsModel) @@ -206,7 +211,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { }) }) Describe(`GetAccountSettings(getAccountSettingsOptions *GetAccountSettingsOptions)`, func() { - getAccountSettingsPath := "/api/v1/user/accounts/12345678-abcd-1a2b-a1b2-1234567890ab/settings" + getAccountSettingsPath := "/api/v1/user/accounts/testString/settings" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { @@ -236,7 +241,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { // Construct an instance of the GetAccountSettingsOptions model getAccountSettingsOptionsModel := new(ibmcloudshellv1.GetAccountSettingsOptions) - getAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") + getAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") getAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -295,7 +300,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { // Construct an instance of the GetAccountSettingsOptions model getAccountSettingsOptionsModel := new(ibmcloudshellv1.GetAccountSettingsOptions) - getAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") + getAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") getAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -315,7 +320,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { // Construct an instance of the GetAccountSettingsOptions model getAccountSettingsOptionsModel := new(ibmcloudshellv1.GetAccountSettingsOptions) - getAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") + getAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") getAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := ibmCloudShellService.SetServiceURL("") @@ -356,7 +361,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { // Construct an instance of the GetAccountSettingsOptions model getAccountSettingsOptionsModel := new(ibmcloudshellv1.GetAccountSettingsOptions) - getAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") + getAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") getAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -373,7 +378,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { }) }) Describe(`UpdateAccountSettings(updateAccountSettingsOptions *UpdateAccountSettingsOptions) - Operation response error`, func() { - updateAccountSettingsPath := "/api/v1/user/accounts/12345678-abcd-1a2b-a1b2-1234567890ab/settings" + updateAccountSettingsPath := "/api/v1/user/accounts/testString/settings" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { @@ -384,7 +389,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke UpdateAccountSettings with error: Operation response processing error`, func() { @@ -395,41 +400,25 @@ var _ = Describe(`IBMCloudShellV1`, func() { Expect(serviceErr).To(BeNil()) Expect(ibmCloudShellService).ToNot(BeNil()) - featureModel := []ibmcloudshellv1.Feature{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.file_manager"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.web_preview"), - }, - } - - regionSettingModel := []ibmcloudshellv1.RegionSetting{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("eu-de"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("jp-tok"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("us-south"), - }, - } + // Construct an instance of the Feature model + featureModel := new(ibmcloudshellv1.Feature) + featureModel.Enabled = core.BoolPtr(true) + featureModel.Key = core.StringPtr("testString") + + // Construct an instance of the RegionSetting model + regionSettingModel := new(ibmcloudshellv1.RegionSetting) + regionSettingModel.Enabled = core.BoolPtr(true) + regionSettingModel.Key = core.StringPtr("testString") // Construct an instance of the UpdateAccountSettingsOptions model updateAccountSettingsOptionsModel := new(ibmcloudshellv1.UpdateAccountSettingsOptions) - updateAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") - updateAccountSettingsOptionsModel.Rev = core.StringPtr("130-12345678-abcd-1a2b-a1b2-1234567890ab") + updateAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsOptionsModel.Rev = core.StringPtr("testString") updateAccountSettingsOptionsModel.DefaultEnableNewFeatures = core.BoolPtr(true) updateAccountSettingsOptionsModel.DefaultEnableNewRegions = core.BoolPtr(true) updateAccountSettingsOptionsModel.Enabled = core.BoolPtr(true) - updateAccountSettingsOptionsModel.Features = featureModel - updateAccountSettingsOptionsModel.Regions = regionSettingModel + updateAccountSettingsOptionsModel.Features = []ibmcloudshellv1.Feature{*featureModel} + updateAccountSettingsOptionsModel.Regions = []ibmcloudshellv1.RegionSetting{*regionSettingModel} updateAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := ibmCloudShellService.UpdateAccountSettings(updateAccountSettingsOptionsModel) @@ -450,7 +439,7 @@ var _ = Describe(`IBMCloudShellV1`, func() { }) }) Describe(`UpdateAccountSettings(updateAccountSettingsOptions *UpdateAccountSettingsOptions)`, func() { - updateAccountSettingsPath := "/api/v1/user/accounts/12345678-abcd-1a2b-a1b2-1234567890ab/settings" + updateAccountSettingsPath := "/api/v1/user/accounts/testString/settings" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { @@ -494,41 +483,25 @@ var _ = Describe(`IBMCloudShellV1`, func() { Expect(ibmCloudShellService).ToNot(BeNil()) ibmCloudShellService.EnableRetries(0, 0) - featureModel := []ibmcloudshellv1.Feature{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.file_manager"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.web_preview"), - }, - } - - regionSettingModel := []ibmcloudshellv1.RegionSetting{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("eu-de"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("jp-tok"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("us-south"), - }, - } + // Construct an instance of the Feature model + featureModel := new(ibmcloudshellv1.Feature) + featureModel.Enabled = core.BoolPtr(true) + featureModel.Key = core.StringPtr("testString") + + // Construct an instance of the RegionSetting model + regionSettingModel := new(ibmcloudshellv1.RegionSetting) + regionSettingModel.Enabled = core.BoolPtr(true) + regionSettingModel.Key = core.StringPtr("testString") // Construct an instance of the UpdateAccountSettingsOptions model updateAccountSettingsOptionsModel := new(ibmcloudshellv1.UpdateAccountSettingsOptions) - updateAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") - updateAccountSettingsOptionsModel.Rev = core.StringPtr("130-12345678-abcd-1a2b-a1b2-1234567890ab") + updateAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsOptionsModel.Rev = core.StringPtr("testString") updateAccountSettingsOptionsModel.DefaultEnableNewFeatures = core.BoolPtr(true) updateAccountSettingsOptionsModel.DefaultEnableNewRegions = core.BoolPtr(true) updateAccountSettingsOptionsModel.Enabled = core.BoolPtr(true) - updateAccountSettingsOptionsModel.Features = featureModel - updateAccountSettingsOptionsModel.Regions = regionSettingModel + updateAccountSettingsOptionsModel.Features = []ibmcloudshellv1.Feature{*featureModel} + updateAccountSettingsOptionsModel.Regions = []ibmcloudshellv1.RegionSetting{*regionSettingModel} updateAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -601,41 +574,25 @@ var _ = Describe(`IBMCloudShellV1`, func() { Expect(response).To(BeNil()) Expect(result).To(BeNil()) - featureModel := []ibmcloudshellv1.Feature{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.file_manager"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.web_preview"), - }, - } - - regionSettingModel := []ibmcloudshellv1.RegionSetting{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("eu-de"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("jp-tok"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("us-south"), - }, - } + // Construct an instance of the Feature model + featureModel := new(ibmcloudshellv1.Feature) + featureModel.Enabled = core.BoolPtr(true) + featureModel.Key = core.StringPtr("testString") + + // Construct an instance of the RegionSetting model + regionSettingModel := new(ibmcloudshellv1.RegionSetting) + regionSettingModel.Enabled = core.BoolPtr(true) + regionSettingModel.Key = core.StringPtr("testString") // Construct an instance of the UpdateAccountSettingsOptions model updateAccountSettingsOptionsModel := new(ibmcloudshellv1.UpdateAccountSettingsOptions) - updateAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") - updateAccountSettingsOptionsModel.Rev = core.StringPtr("130-12345678-abcd-1a2b-a1b2-1234567890ab") + updateAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsOptionsModel.Rev = core.StringPtr("testString") updateAccountSettingsOptionsModel.DefaultEnableNewFeatures = core.BoolPtr(true) updateAccountSettingsOptionsModel.DefaultEnableNewRegions = core.BoolPtr(true) updateAccountSettingsOptionsModel.Enabled = core.BoolPtr(true) - updateAccountSettingsOptionsModel.Features = featureModel - updateAccountSettingsOptionsModel.Regions = regionSettingModel + updateAccountSettingsOptionsModel.Features = []ibmcloudshellv1.Feature{*featureModel} + updateAccountSettingsOptionsModel.Regions = []ibmcloudshellv1.RegionSetting{*regionSettingModel} updateAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -653,41 +610,25 @@ var _ = Describe(`IBMCloudShellV1`, func() { Expect(serviceErr).To(BeNil()) Expect(ibmCloudShellService).ToNot(BeNil()) - featureModel := []ibmcloudshellv1.Feature{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.file_manager"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.web_preview"), - }, - } - - regionSettingModel := []ibmcloudshellv1.RegionSetting{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("eu-de"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("jp-tok"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("us-south"), - }, - } + // Construct an instance of the Feature model + featureModel := new(ibmcloudshellv1.Feature) + featureModel.Enabled = core.BoolPtr(true) + featureModel.Key = core.StringPtr("testString") + + // Construct an instance of the RegionSetting model + regionSettingModel := new(ibmcloudshellv1.RegionSetting) + regionSettingModel.Enabled = core.BoolPtr(true) + regionSettingModel.Key = core.StringPtr("testString") // Construct an instance of the UpdateAccountSettingsOptions model updateAccountSettingsOptionsModel := new(ibmcloudshellv1.UpdateAccountSettingsOptions) - updateAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") - updateAccountSettingsOptionsModel.Rev = core.StringPtr("130-12345678-abcd-1a2b-a1b2-1234567890ab") + updateAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsOptionsModel.Rev = core.StringPtr("testString") updateAccountSettingsOptionsModel.DefaultEnableNewFeatures = core.BoolPtr(true) updateAccountSettingsOptionsModel.DefaultEnableNewRegions = core.BoolPtr(true) updateAccountSettingsOptionsModel.Enabled = core.BoolPtr(true) - updateAccountSettingsOptionsModel.Features = featureModel - updateAccountSettingsOptionsModel.Regions = regionSettingModel + updateAccountSettingsOptionsModel.Features = []ibmcloudshellv1.Feature{*featureModel} + updateAccountSettingsOptionsModel.Regions = []ibmcloudshellv1.RegionSetting{*regionSettingModel} updateAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := ibmCloudShellService.SetServiceURL("") @@ -726,41 +667,25 @@ var _ = Describe(`IBMCloudShellV1`, func() { Expect(serviceErr).To(BeNil()) Expect(ibmCloudShellService).ToNot(BeNil()) - featureModel := []ibmcloudshellv1.Feature{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.file_manager"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("server.web_preview"), - }, - } - - regionSettingModel := []ibmcloudshellv1.RegionSetting{ - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("eu-de"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("jp-tok"), - }, - { - Enabled: core.BoolPtr(true), - Key: core.StringPtr("us-south"), - }, - } + // Construct an instance of the Feature model + featureModel := new(ibmcloudshellv1.Feature) + featureModel.Enabled = core.BoolPtr(true) + featureModel.Key = core.StringPtr("testString") + + // Construct an instance of the RegionSetting model + regionSettingModel := new(ibmcloudshellv1.RegionSetting) + regionSettingModel.Enabled = core.BoolPtr(true) + regionSettingModel.Key = core.StringPtr("testString") // Construct an instance of the UpdateAccountSettingsOptions model updateAccountSettingsOptionsModel := new(ibmcloudshellv1.UpdateAccountSettingsOptions) - updateAccountSettingsOptionsModel.AccountID = core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab") - updateAccountSettingsOptionsModel.Rev = core.StringPtr("130-12345678-abcd-1a2b-a1b2-1234567890ab") + updateAccountSettingsOptionsModel.AccountID = core.StringPtr("testString") + updateAccountSettingsOptionsModel.Rev = core.StringPtr("testString") updateAccountSettingsOptionsModel.DefaultEnableNewFeatures = core.BoolPtr(true) updateAccountSettingsOptionsModel.DefaultEnableNewRegions = core.BoolPtr(true) updateAccountSettingsOptionsModel.Enabled = core.BoolPtr(true) - updateAccountSettingsOptionsModel.Features = featureModel - updateAccountSettingsOptionsModel.Regions = regionSettingModel + updateAccountSettingsOptionsModel.Features = []ibmcloudshellv1.Feature{*featureModel} + updateAccountSettingsOptionsModel.Regions = []ibmcloudshellv1.RegionSetting{*regionSettingModel} updateAccountSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -784,12 +709,12 @@ var _ = Describe(`IBMCloudShellV1`, func() { }) It(`Invoke NewGetAccountSettingsOptions successfully`, func() { // Construct an instance of the GetAccountSettingsOptions model - accountID := "12345678-abcd-1a2b-a1b2-1234567890ab" + accountID := "testString" getAccountSettingsOptionsModel := ibmCloudShellService.NewGetAccountSettingsOptions(accountID) - getAccountSettingsOptionsModel.SetAccountID("12345678-abcd-1a2b-a1b2-1234567890ab") + getAccountSettingsOptionsModel.SetAccountID("testString") getAccountSettingsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(getAccountSettingsOptionsModel).ToNot(BeNil()) - Expect(getAccountSettingsOptionsModel.AccountID).To(Equal(core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab"))) + Expect(getAccountSettingsOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) Expect(getAccountSettingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateAccountSettingsOptions successfully`, func() { @@ -797,23 +722,23 @@ var _ = Describe(`IBMCloudShellV1`, func() { featureModel := new(ibmcloudshellv1.Feature) Expect(featureModel).ToNot(BeNil()) featureModel.Enabled = core.BoolPtr(true) - featureModel.Key = core.StringPtr("server.file_manager") + featureModel.Key = core.StringPtr("testString") Expect(featureModel.Enabled).To(Equal(core.BoolPtr(true))) - Expect(featureModel.Key).To(Equal(core.StringPtr("server.file_manager"))) + Expect(featureModel.Key).To(Equal(core.StringPtr("testString"))) // Construct an instance of the RegionSetting model regionSettingModel := new(ibmcloudshellv1.RegionSetting) Expect(regionSettingModel).ToNot(BeNil()) regionSettingModel.Enabled = core.BoolPtr(true) - regionSettingModel.Key = core.StringPtr("eu-de") + regionSettingModel.Key = core.StringPtr("testString") Expect(regionSettingModel.Enabled).To(Equal(core.BoolPtr(true))) - Expect(regionSettingModel.Key).To(Equal(core.StringPtr("eu-de"))) + Expect(regionSettingModel.Key).To(Equal(core.StringPtr("testString"))) // Construct an instance of the UpdateAccountSettingsOptions model - accountID := "12345678-abcd-1a2b-a1b2-1234567890ab" + accountID := "testString" updateAccountSettingsOptionsModel := ibmCloudShellService.NewUpdateAccountSettingsOptions(accountID) - updateAccountSettingsOptionsModel.SetAccountID("12345678-abcd-1a2b-a1b2-1234567890ab") - updateAccountSettingsOptionsModel.SetRev("130-12345678-abcd-1a2b-a1b2-1234567890ab") + updateAccountSettingsOptionsModel.SetAccountID("testString") + updateAccountSettingsOptionsModel.SetRev("testString") updateAccountSettingsOptionsModel.SetDefaultEnableNewFeatures(true) updateAccountSettingsOptionsModel.SetDefaultEnableNewRegions(true) updateAccountSettingsOptionsModel.SetEnabled(true) @@ -821,8 +746,8 @@ var _ = Describe(`IBMCloudShellV1`, func() { updateAccountSettingsOptionsModel.SetRegions([]ibmcloudshellv1.RegionSetting{*regionSettingModel}) updateAccountSettingsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateAccountSettingsOptionsModel).ToNot(BeNil()) - Expect(updateAccountSettingsOptionsModel.AccountID).To(Equal(core.StringPtr("12345678-abcd-1a2b-a1b2-1234567890ab"))) - Expect(updateAccountSettingsOptionsModel.Rev).To(Equal(core.StringPtr("130-12345678-abcd-1a2b-a1b2-1234567890ab"))) + Expect(updateAccountSettingsOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(updateAccountSettingsOptionsModel.Rev).To(Equal(core.StringPtr("testString"))) Expect(updateAccountSettingsOptionsModel.DefaultEnableNewFeatures).To(Equal(core.BoolPtr(true))) Expect(updateAccountSettingsOptionsModel.DefaultEnableNewRegions).To(Equal(core.BoolPtr(true))) Expect(updateAccountSettingsOptionsModel.Enabled).To(Equal(core.BoolPtr(true))) @@ -832,9 +757,79 @@ var _ = Describe(`IBMCloudShellV1`, func() { }) }) }) + Describe(`Model unmarshaling tests`, func() { + It(`Invoke UnmarshalAccountSettings successfully`, func() { + // Construct an instance of the model. + model := new(ibmcloudshellv1.AccountSettings) + model.ID = core.StringPtr("testString") + model.Rev = core.StringPtr("testString") + model.AccountID = core.StringPtr("testString") + model.CreatedAt = core.Int64Ptr(int64(38)) + model.CreatedBy = core.StringPtr("testString") + model.DefaultEnableNewFeatures = core.BoolPtr(true) + model.DefaultEnableNewRegions = core.BoolPtr(true) + model.Enabled = core.BoolPtr(true) + model.Features = nil + model.Regions = nil + model.Type = core.StringPtr("testString") + model.UpdatedAt = core.Int64Ptr(int64(38)) + model.UpdatedBy = core.StringPtr("testString") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *ibmcloudshellv1.AccountSettings + err = ibmcloudshellv1.UnmarshalAccountSettings(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalFeature successfully`, func() { + // Construct an instance of the model. + model := new(ibmcloudshellv1.Feature) + model.Enabled = core.BoolPtr(true) + model.Key = core.StringPtr("testString") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *ibmcloudshellv1.Feature + err = ibmcloudshellv1.UnmarshalFeature(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalRegionSetting successfully`, func() { + // Construct an instance of the model. + model := new(ibmcloudshellv1.RegionSetting) + model.Enabled = core.BoolPtr(true) + model.Key = core.StringPtr("testString") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *ibmcloudshellv1.RegionSetting + err = ibmcloudshellv1.UnmarshalRegionSetting(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + }) Describe(`Utility function tests`, func() { It(`Invoke CreateMockByteArray() successfully`, func() { - mockByteArray := CreateMockByteArray("This is a test") + mockByteArray := CreateMockByteArray("VGhpcyBpcyBhIHRlc3Qgb2YgdGhlIGVtZXJnZW5jeSBicm9hZGNhc3Qgc3lzdGVt") Expect(mockByteArray).ToNot(BeNil()) }) It(`Invoke CreateMockUUID() successfully`, func() { @@ -860,9 +855,11 @@ var _ = Describe(`IBMCloudShellV1`, func() { // Utility functions used by the generated test code // -func CreateMockByteArray(mockData string) *[]byte { - ba := make([]byte, 0) - ba = append(ba, mockData...) +func CreateMockByteArray(encodedString string) *[]byte { + ba, err := base64.StdEncoding.DecodeString(encodedString) + if err != nil { + panic(err) + } return &ba }