Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/tools/github.com/golan…
Browse files Browse the repository at this point in the history
…gci/golangci-lint-1.58.0
  • Loading branch information
nachtjasmin authored May 22, 2024
2 parents 429b061 + b1c0ae7 commit f90d3bf
Show file tree
Hide file tree
Showing 16 changed files with 362 additions and 81 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ Some examples, more below in the actual changelog (newer entries are more likely
-->

### Added
* `WithRequestOptions` API option to configure default request options (#361, @anx-mschaefer)
* kubernetes/v1: Add `autoscaling` attribute via `EnableAutoscaling` field (#369, @nachtjasmin)

### Changed
* (internal) add "error-return" to request option interfaces (#361, @anx-mschaefer)

## [0.6.4] - 2024-03-15

### Fixed
Expand Down
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ require (
github.com/go-logr/logr v1.4.1
github.com/go-logr/stdr v1.2.2
github.com/mitchellh/copystructure v1.2.0
github.com/onsi/ginkgo/v2 v2.16.0
github.com/onsi/gomega v1.31.1
github.com/onsi/ginkgo/v2 v2.17.2
github.com/onsi/gomega v1.33.1
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
golang.org/x/crypto v0.23.0
)

require (
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
44 changes: 13 additions & 31 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,59 +1,41 @@
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg=
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM=
github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo=
github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0=
github.com/onsi/ginkgo/v2 v2.17.2 h1:7eMhcy3GimbsA3hEnVKdw/PQM9XN9krpKVXsZdph0/g=
github.com/onsi/ginkgo/v2 v2.17.2/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc=
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM=
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
67 changes: 55 additions & 12 deletions pkg/api/api_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"mime"
Expand All @@ -30,7 +31,8 @@ type defaultAPI struct {
client client.Client
logger *logr.Logger

clientOptions []client.Option
clientOptions []client.Option
requestOptions []types.Option
}

// NewAPIOption is the type for giving options to the NewAPI function.
Expand All @@ -43,6 +45,13 @@ func WithClientOptions(o ...client.Option) NewAPIOption {
}
}

// WithRequestOptions configures default options applied to requests
func WithRequestOptions(opts ...types.Option) NewAPIOption {
return func(a *defaultAPI) {
a.requestOptions = opts
}
}

// WithLogger configures the API to use the given logger. It is recommended to pass a named logger.
// If you don't pass an existing client, the logger you give here will given to the client (with
// added name "client").
Expand Down Expand Up @@ -79,8 +88,12 @@ func NewAPI(opts ...NewAPIOption) (API, error) {
// Get the identified object from the engine.
func (a defaultAPI) Get(ctx context.Context, o types.IdentifiedObject, opts ...types.GetOption) error {
options := types.GetOptions{}
for _, opt := range opts {
opt.ApplyToGet(&options)
var err error
for _, opt := range resolveRequestOptions(a.requestOptions, opts) {
err = errors.Join(err, opt.ApplyToGet(&options))
}
if err != nil {
return fmt.Errorf("apply request options: %w", err)
}

return a.do(ctx, o, o, &options, types.OperationGet)
Expand All @@ -89,8 +102,12 @@ func (a defaultAPI) Get(ctx context.Context, o types.IdentifiedObject, opts ...t
// Create the given object on the engine.
func (a defaultAPI) Create(ctx context.Context, o types.Object, opts ...types.CreateOption) error {
options := types.CreateOptions{}
for _, opt := range opts {
opt.ApplyToCreate(&options)
var err error
for _, opt := range resolveRequestOptions(a.requestOptions, opts) {
err = errors.Join(err, opt.ApplyToCreate(&options))
}
if err != nil {
return fmt.Errorf("apply request options: %w", err)
}

if err := a.do(ctx, o, o, &options, types.OperationCreate); err != nil {
Expand All @@ -115,8 +132,12 @@ func (a defaultAPI) handlePostCreateOptions(ctx context.Context, o types.Identif
// Update the object on the engine.
func (a defaultAPI) Update(ctx context.Context, o types.IdentifiedObject, opts ...types.UpdateOption) error {
options := types.UpdateOptions{}
for _, opt := range opts {
opt.ApplyToUpdate(&options)
var err error
for _, opt := range resolveRequestOptions(a.requestOptions, opts) {
err = errors.Join(err, opt.ApplyToUpdate(&options))
}
if err != nil {
return fmt.Errorf("apply request options: %w", err)
}

return a.do(ctx, o, o, &options, types.OperationUpdate)
Expand All @@ -125,8 +146,12 @@ func (a defaultAPI) Update(ctx context.Context, o types.IdentifiedObject, opts .
// Destroy the identified object.
func (a defaultAPI) Destroy(ctx context.Context, o types.IdentifiedObject, opts ...types.DestroyOption) error {
options := types.DestroyOptions{}
for _, opt := range opts {
opt.ApplyToDestroy(&options)
var err error
for _, opt := range resolveRequestOptions(a.requestOptions, opts) {
err = errors.Join(err, opt.ApplyToDestroy(&options))
}
if err != nil {
return fmt.Errorf("apply request options: %w", err)
}

return a.do(ctx, o, o, &options, types.OperationDestroy)
Expand All @@ -135,11 +160,14 @@ func (a defaultAPI) Destroy(ctx context.Context, o types.IdentifiedObject, opts
// List objects matching the info given in the object.
func (a defaultAPI) List(ctx context.Context, o types.FilterObject, opts ...types.ListOption) error {
options := types.ListOptions{}
for _, opt := range opts {
opt.ApplyToList(&options)
var err error
for _, opt := range resolveRequestOptions(a.requestOptions, opts) {
err = errors.Join(err, opt.ApplyToList(&options))
}
if err != nil {
return fmt.Errorf("apply request options: %w", err)
}

var err error
ctx, err = a.contextPrepare(ctx, o, types.OperationList, &options)

if err != nil {
Expand Down Expand Up @@ -515,3 +543,18 @@ func decodeResponse(ctx context.Context, mediaType string, data io.Reader, res i

return fmt.Errorf("%w: no idea how to handle media type %v", ErrUnsupportedResponseFormat, mediaType)
}

func resolveRequestOptions[T any](commonOptions []types.Option, requestOptions []T) []T {
return append(filterOptions[T](commonOptions), requestOptions...)
}

func filterOptions[T any](opts []types.Option) []T {
ret := make([]T, 0, len(opts))
for _, v := range opts {
if v, ok := v.(T); ok {
ret = append(ret, v)
}
}

return ret
}
107 changes: 97 additions & 10 deletions pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,30 @@ var _ = Describe("getResponseType function", func() {

type apiTestAnyopOption string

func (o apiTestAnyopOption) ApplyToGet(opts *types.GetOptions) {
_ = opts.Set("api_test_option", o, false)
func (o apiTestAnyopOption) ApplyToGet(opts *types.GetOptions) error {
return opts.Set("api_test_option", o, false)
}

func (o apiTestAnyopOption) ApplyToList(opts *types.ListOptions) {
_ = opts.Set("api_test_option", o, false)
func (o apiTestAnyopOption) ApplyToList(opts *types.ListOptions) error {
return opts.Set("api_test_option", o, false)
}

func (o apiTestAnyopOption) ApplyToCreate(opts *types.CreateOptions) {
_ = opts.Set("api_test_option", o, false)
func (o apiTestAnyopOption) ApplyToCreate(opts *types.CreateOptions) error {
return opts.Set("api_test_option", o, false)
}

func (o apiTestAnyopOption) ApplyToUpdate(opts *types.UpdateOptions) {
_ = opts.Set("api_test_option", o, false)
func (o apiTestAnyopOption) ApplyToUpdate(opts *types.UpdateOptions) error {
return opts.Set("api_test_option", o, false)
}

func (o apiTestAnyopOption) ApplyToDestroy(opts *types.DestroyOptions) {
_ = opts.Set("api_test_option", o, false)
func (o apiTestAnyopOption) ApplyToDestroy(opts *types.DestroyOptions) error {
return opts.Set("api_test_option", o, false)
}

func errorOption(err error) types.AnyOption {
return func(o types.Options) error {
return err
}
}

type apiTestObject struct {
Expand Down Expand Up @@ -1025,6 +1031,87 @@ var _ = Describe("using an API object", func() {
err = api.Destroy(ctx, &o, opt)
Expect(err).NotTo(HaveOccurred())
})

It("consumes the default options for all operations", func() {
opt := apiTestAnyopOption("hello world")
ctx := context.WithValue(context.TODO(), errAPITest, opt)

server.AppendHandlers(
ghttp.RespondWithJSONEncoded(200, map[string]string{"value": "option-check"}),
ghttp.RespondWithJSONEncoded(200, map[string]string{"value": "option-check"}),
ghttp.RespondWithJSONEncoded(200, []map[string]string{{"value": "option-check"}}),
ghttp.RespondWithJSONEncoded(200, map[string]string{"value": "option-check"}),
ghttp.RespondWithJSONEncoded(200, map[string]string{}),
)

api, err := NewAPI(
WithLogger(logger),
WithClientOptions(
client.BaseURL(server.URL()),
client.IgnoreMissingToken(),
),
WithRequestOptions(opt),
)
Expect(err).NotTo(HaveOccurred())

o := apiTestObject{"option-check"}

err = api.Create(ctx, &o)
Expect(err).NotTo(HaveOccurred())

err = api.Get(ctx, &o)
Expect(err).NotTo(HaveOccurred())

err = api.List(ctx, &o)
Expect(err).NotTo(HaveOccurred())

err = api.Update(ctx, &o)
Expect(err).NotTo(HaveOccurred())

err = api.Destroy(ctx, &o)
Expect(err).NotTo(HaveOccurred())
})

It("returns an error when applying configured options return errors", func() {
mockErr := errors.New("foo")
api, err := NewAPI(
WithLogger(logger),
WithClientOptions(
client.BaseURL(server.URL()),
client.IgnoreMissingToken(),
),
)
Expect(err).NotTo(HaveOccurred())

o := apiTestObject{"foo"}

Expect(api.Create(context.TODO(), &o, errorOption(mockErr))).Error().To(MatchError(mockErr))
Expect(api.Get(context.TODO(), &o, errorOption(mockErr))).Error().To(MatchError(mockErr))
Expect(api.List(context.TODO(), &o, errorOption(mockErr))).Error().To(MatchError(mockErr))
Expect(api.Update(context.TODO(), &o, errorOption(mockErr))).Error().To(MatchError(mockErr))
Expect(api.Destroy(context.TODO(), &o, errorOption(mockErr))).Error().To(MatchError(mockErr))
})

It("returns an error when applying configured default options return errors", func() {
mockErr := errors.New("foo")
api, err := NewAPI(
WithLogger(logger),
WithClientOptions(
client.BaseURL(server.URL()),
client.IgnoreMissingToken(),
),
WithRequestOptions(errorOption(mockErr)),
)
Expect(err).NotTo(HaveOccurred())

o := apiTestObject{"foo"}

Expect(api.Create(context.TODO(), &o)).Error().To(MatchError(mockErr))
Expect(api.Get(context.TODO(), &o)).Error().To(MatchError(mockErr))
Expect(api.List(context.TODO(), &o)).Error().To(MatchError(mockErr))
Expect(api.Update(context.TODO(), &o)).Error().To(MatchError(mockErr))
Expect(api.Destroy(context.TODO(), &o)).Error().To(MatchError(mockErr))
})
})

const contextTestObjectBaseurl = "/v1/context_test_object"
Expand Down
Loading

0 comments on commit f90d3bf

Please sign in to comment.