From 7e6fc91c83187160f302962b250509cffe8c406c Mon Sep 17 00:00:00 2001 From: Artyom Matantsev Date: Fri, 12 Jul 2024 12:29:01 +0300 Subject: [PATCH] Add Github Actions workflow --- .github/PULL_REQUEST_TEMPLATE.md | 3 + .github/workflows/test.yaml | 56 +++++++ go.mod | 1 - go.sum | 9 +- pkg/diskapi/diskapi.go | 2 +- pkg/diskapi/mocks/disk_api.go | 151 +++++++++++------- .../mock/computemocks/disk_service_server.go | 2 +- .../computemocks/instance_service_server.go | 2 +- .../mock/computemocks/zone_service_server.go | 2 +- .../api_endpoint_service_server.go | 2 +- .../mock/iammocks/iam_token_service_server.go | 2 +- .../service_account_service_server.go | 2 +- .../cloud_service_server.go | 2 +- .../folder_service_server.go | 2 +- 14 files changed, 169 insertions(+), 69 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/test.yaml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4c673ff --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,3 @@ +**What this PR does?** + +**How was it tested?** \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..d79d0c0 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,56 @@ +# Copyright 2024 YANDEX LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Run tests + +on: + pull_request: {} + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Tidy + run: go mod tidy && git diff --exit-code + + - name: Install dependencies + run: go install github.com/vektra/mockery/v2@v2.43.2 + + - name: Generate + run: go generate ./... && git diff --exit-code + + - name: Build + run: go build -o=/dev/null ./cmd/... + + - name: Lint + uses: golangci/golangci-lint-action@v5.0.0 + with: + args: --timeout 3m + + - name: Run tests + run: go test -race -shuffle=on -v ./... \ No newline at end of file diff --git a/go.mod b/go.mod index 3594cfd..7a48e3a 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,6 @@ require ( github.com/opencontainers/selinux v1.10.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.5.0 // indirect - go.uber.org/mock v0.3.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/go.sum b/go.sum index 0a37c42..142006b 100644 --- a/go.sum +++ b/go.sum @@ -46,6 +46,7 @@ github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= 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-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= @@ -78,6 +79,7 @@ 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/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= @@ -90,6 +92,7 @@ github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHh github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kubernetes-csi/csi-test/v4 v4.4.0 h1:r0mnAwDURI24Vw3a/LyA/ga11yD5ZGuU7+REO35Na9s= @@ -109,6 +112,7 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= @@ -122,6 +126,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -140,8 +145,6 @@ github.com/yandex-cloud/go-sdk v0.0.0-20231204111359-25f2607c41ac/go.mod h1:49Bw github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= -go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -216,6 +219,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -263,6 +267,7 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= diff --git a/pkg/diskapi/diskapi.go b/pkg/diskapi/diskapi.go index b923a54..6015501 100644 --- a/pkg/diskapi/diskapi.go +++ b/pkg/diskapi/diskapi.go @@ -150,7 +150,7 @@ type EnsureObjectLabelsRequest struct { Instance *Instance } -//go:generate mockery -name=DiskAPI -outpkg=diskapimocks +//go:generate mockery --name=DiskAPI --outpkg=diskapimocks --case=underscore type DiskAPI interface { CreateDisk(context.Context, *CreateDiskRequest) (*Disk, error) // Attach,Detach,Delete return success when operation has already been done earlier. diff --git a/pkg/diskapi/mocks/disk_api.go b/pkg/diskapi/mocks/disk_api.go index 4d4afe7..74cc09b 100644 --- a/pkg/diskapi/mocks/disk_api.go +++ b/pkg/diskapi/mocks/disk_api.go @@ -1,13 +1,12 @@ -// Code generated by Yandex patched mockery v1.1.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package diskapimocks import ( context "context" - "github.com/yandex-cloud/yc-csi-driver/pkg/diskapi" - mock "github.com/stretchr/testify/mock" + diskapi "github.com/yandex-cloud/yc-csi-driver/pkg/diskapi" ) // DiskAPI is an autogenerated mock type for the DiskAPI type @@ -19,6 +18,10 @@ type DiskAPI struct { func (_m *DiskAPI) AttachDisk(_a0 context.Context, _a1 *diskapi.AttachDiskRequest) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for AttachDisk") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *diskapi.AttachDiskRequest) error); ok { r0 = rf(_a0, _a1) @@ -33,14 +36,15 @@ func (_m *DiskAPI) AttachDisk(_a0 context.Context, _a1 *diskapi.AttachDiskReques func (_m *DiskAPI) CreateDisk(_a0 context.Context, _a1 *diskapi.CreateDiskRequest) (*diskapi.Disk, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.CreateDiskRequest) (*diskapi.Disk, error)) - if ok { - return rf(_a0, _a1) - } + if len(ret) == 0 { + panic("no return value specified for CreateDisk") } var r0 *diskapi.Disk + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.CreateDiskRequest) (*diskapi.Disk, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.CreateDiskRequest) *diskapi.Disk); ok { r0 = rf(_a0, _a1) } else { @@ -49,7 +53,6 @@ func (_m *DiskAPI) CreateDisk(_a0 context.Context, _a1 *diskapi.CreateDiskReques } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.CreateDiskRequest) error); ok { r1 = rf(_a0, _a1) } else { @@ -63,14 +66,15 @@ func (_m *DiskAPI) CreateDisk(_a0 context.Context, _a1 *diskapi.CreateDiskReques func (_m *DiskAPI) CreateSnapshot(_a0 context.Context, _a1 *diskapi.CreateSnapshotRequest) (*diskapi.Snapshot, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.CreateSnapshotRequest) (*diskapi.Snapshot, error)) - if ok { - return rf(_a0, _a1) - } + if len(ret) == 0 { + panic("no return value specified for CreateSnapshot") } var r0 *diskapi.Snapshot + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.CreateSnapshotRequest) (*diskapi.Snapshot, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.CreateSnapshotRequest) *diskapi.Snapshot); ok { r0 = rf(_a0, _a1) } else { @@ -79,7 +83,6 @@ func (_m *DiskAPI) CreateSnapshot(_a0 context.Context, _a1 *diskapi.CreateSnapsh } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.CreateSnapshotRequest) error); ok { r1 = rf(_a0, _a1) } else { @@ -93,6 +96,10 @@ func (_m *DiskAPI) CreateSnapshot(_a0 context.Context, _a1 *diskapi.CreateSnapsh func (_m *DiskAPI) DeleteDisk(_a0 context.Context, _a1 *diskapi.DeleteDiskRequest) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for DeleteDisk") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *diskapi.DeleteDiskRequest) error); ok { r0 = rf(_a0, _a1) @@ -107,6 +114,10 @@ func (_m *DiskAPI) DeleteDisk(_a0 context.Context, _a1 *diskapi.DeleteDiskReques func (_m *DiskAPI) DeleteSnapshot(_a0 context.Context, _a1 *diskapi.DeleteSnapshotRequest) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for DeleteSnapshot") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *diskapi.DeleteSnapshotRequest) error); ok { r0 = rf(_a0, _a1) @@ -121,6 +132,10 @@ func (_m *DiskAPI) DeleteSnapshot(_a0 context.Context, _a1 *diskapi.DeleteSnapsh func (_m *DiskAPI) DetachDisk(_a0 context.Context, _a1 *diskapi.DetachDiskRequest) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for DetachDisk") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *diskapi.DetachDiskRequest) error); ok { r0 = rf(_a0, _a1) @@ -135,6 +150,10 @@ func (_m *DiskAPI) DetachDisk(_a0 context.Context, _a1 *diskapi.DetachDiskReques func (_m *DiskAPI) EnsureObjectLabels(ctx context.Context, req *diskapi.EnsureObjectLabelsRequest) error { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for EnsureObjectLabels") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *diskapi.EnsureObjectLabelsRequest) error); ok { r0 = rf(ctx, req) @@ -149,6 +168,10 @@ func (_m *DiskAPI) EnsureObjectLabels(ctx context.Context, req *diskapi.EnsureOb func (_m *DiskAPI) ExpandDisk(_a0 context.Context, _a1 *diskapi.ExpandDiskRequest) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for ExpandDisk") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *diskapi.ExpandDiskRequest) error); ok { r0 = rf(_a0, _a1) @@ -163,14 +186,15 @@ func (_m *DiskAPI) ExpandDisk(_a0 context.Context, _a1 *diskapi.ExpandDiskReques func (_m *DiskAPI) GetDisk(_a0 context.Context, _a1 *diskapi.GetDiskRequest) (*diskapi.Disk, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetDiskRequest) (*diskapi.Disk, error)) - if ok { - return rf(_a0, _a1) - } + if len(ret) == 0 { + panic("no return value specified for GetDisk") } var r0 *diskapi.Disk + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetDiskRequest) (*diskapi.Disk, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetDiskRequest) *diskapi.Disk); ok { r0 = rf(_a0, _a1) } else { @@ -179,7 +203,6 @@ func (_m *DiskAPI) GetDisk(_a0 context.Context, _a1 *diskapi.GetDiskRequest) (*d } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.GetDiskRequest) error); ok { r1 = rf(_a0, _a1) } else { @@ -193,14 +216,15 @@ func (_m *DiskAPI) GetDisk(_a0 context.Context, _a1 *diskapi.GetDiskRequest) (*d func (_m *DiskAPI) GetDiskByName(_a0 context.Context, _a1 *diskapi.GetDiskByNameRequest) (*diskapi.Disk, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetDiskByNameRequest) (*diskapi.Disk, error)) - if ok { - return rf(_a0, _a1) - } + if len(ret) == 0 { + panic("no return value specified for GetDiskByName") } var r0 *diskapi.Disk + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetDiskByNameRequest) (*diskapi.Disk, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetDiskByNameRequest) *diskapi.Disk); ok { r0 = rf(_a0, _a1) } else { @@ -209,7 +233,6 @@ func (_m *DiskAPI) GetDiskByName(_a0 context.Context, _a1 *diskapi.GetDiskByName } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.GetDiskByNameRequest) error); ok { r1 = rf(_a0, _a1) } else { @@ -223,14 +246,15 @@ func (_m *DiskAPI) GetDiskByName(_a0 context.Context, _a1 *diskapi.GetDiskByName func (_m *DiskAPI) GetInstance(_a0 context.Context, _a1 *diskapi.GetInstanceRequest) (*diskapi.Instance, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetInstanceRequest) (*diskapi.Instance, error)) - if ok { - return rf(_a0, _a1) - } + if len(ret) == 0 { + panic("no return value specified for GetInstance") } var r0 *diskapi.Instance + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetInstanceRequest) (*diskapi.Instance, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetInstanceRequest) *diskapi.Instance); ok { r0 = rf(_a0, _a1) } else { @@ -239,7 +263,6 @@ func (_m *DiskAPI) GetInstance(_a0 context.Context, _a1 *diskapi.GetInstanceRequ } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.GetInstanceRequest) error); ok { r1 = rf(_a0, _a1) } else { @@ -253,14 +276,15 @@ func (_m *DiskAPI) GetInstance(_a0 context.Context, _a1 *diskapi.GetInstanceRequ func (_m *DiskAPI) GetSnapshot(_a0 context.Context, _a1 *diskapi.GetSnapshotRequest) (*diskapi.Snapshot, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetSnapshotRequest) (*diskapi.Snapshot, error)) - if ok { - return rf(_a0, _a1) - } + if len(ret) == 0 { + panic("no return value specified for GetSnapshot") } var r0 *diskapi.Snapshot + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetSnapshotRequest) (*diskapi.Snapshot, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetSnapshotRequest) *diskapi.Snapshot); ok { r0 = rf(_a0, _a1) } else { @@ -269,7 +293,6 @@ func (_m *DiskAPI) GetSnapshot(_a0 context.Context, _a1 *diskapi.GetSnapshotRequ } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.GetSnapshotRequest) error); ok { r1 = rf(_a0, _a1) } else { @@ -283,14 +306,15 @@ func (_m *DiskAPI) GetSnapshot(_a0 context.Context, _a1 *diskapi.GetSnapshotRequ func (_m *DiskAPI) GetSnapshotByName(_a0 context.Context, _a1 *diskapi.GetSnapshotByNameRequest) (*diskapi.Snapshot, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetSnapshotByNameRequest) (*diskapi.Snapshot, error)) - if ok { - return rf(_a0, _a1) - } + if len(ret) == 0 { + panic("no return value specified for GetSnapshotByName") } var r0 *diskapi.Snapshot + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetSnapshotByNameRequest) (*diskapi.Snapshot, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.GetSnapshotByNameRequest) *diskapi.Snapshot); ok { r0 = rf(_a0, _a1) } else { @@ -299,7 +323,6 @@ func (_m *DiskAPI) GetSnapshotByName(_a0 context.Context, _a1 *diskapi.GetSnapsh } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.GetSnapshotByNameRequest) error); ok { r1 = rf(_a0, _a1) } else { @@ -313,14 +336,15 @@ func (_m *DiskAPI) GetSnapshotByName(_a0 context.Context, _a1 *diskapi.GetSnapsh func (_m *DiskAPI) ListDisks(_a0 context.Context, _a1 *diskapi.ListDisksRequest) ([]*diskapi.Disk, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.ListDisksRequest) ([]*diskapi.Disk, error)) - if ok { - return rf(_a0, _a1) - } + if len(ret) == 0 { + panic("no return value specified for ListDisks") } var r0 []*diskapi.Disk + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.ListDisksRequest) ([]*diskapi.Disk, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.ListDisksRequest) []*diskapi.Disk); ok { r0 = rf(_a0, _a1) } else { @@ -329,7 +353,6 @@ func (_m *DiskAPI) ListDisks(_a0 context.Context, _a1 *diskapi.ListDisksRequest) } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.ListDisksRequest) error); ok { r1 = rf(_a0, _a1) } else { @@ -343,14 +366,15 @@ func (_m *DiskAPI) ListDisks(_a0 context.Context, _a1 *diskapi.ListDisksRequest) func (_m *DiskAPI) ListSnapshots(ctx context.Context, req *diskapi.ListSnapshotsRequest) (*diskapi.ListSnapshotsResponse, error) { ret := _m.Called(ctx, req) - if len(ret) == 1 { - rf, ok := ret.Get(0).(func(context.Context, *diskapi.ListSnapshotsRequest) (*diskapi.ListSnapshotsResponse, error)) - if ok { - return rf(ctx, req) - } + if len(ret) == 0 { + panic("no return value specified for ListSnapshots") } var r0 *diskapi.ListSnapshotsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *diskapi.ListSnapshotsRequest) (*diskapi.ListSnapshotsResponse, error)); ok { + return rf(ctx, req) + } if rf, ok := ret.Get(0).(func(context.Context, *diskapi.ListSnapshotsRequest) *diskapi.ListSnapshotsResponse); ok { r0 = rf(ctx, req) } else { @@ -359,7 +383,6 @@ func (_m *DiskAPI) ListSnapshots(ctx context.Context, req *diskapi.ListSnapshots } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *diskapi.ListSnapshotsRequest) error); ok { r1 = rf(ctx, req) } else { @@ -368,3 +391,17 @@ func (_m *DiskAPI) ListSnapshots(ctx context.Context, req *diskapi.ListSnapshots return r0, r1 } + +// NewDiskAPI creates a new instance of DiskAPI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDiskAPI(t interface { + mock.TestingT + Cleanup(func()) +}) *DiskAPI { + mock := &DiskAPI{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/testutil/pubapimock/mock/computemocks/disk_service_server.go b/pkg/testutil/pubapimock/mock/computemocks/disk_service_server.go index b32261c..13ad5a7 100644 --- a/pkg/testutil/pubapimock/mock/computemocks/disk_service_server.go +++ b/pkg/testutil/pubapimock/mock/computemocks/disk_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package computemocks diff --git a/pkg/testutil/pubapimock/mock/computemocks/instance_service_server.go b/pkg/testutil/pubapimock/mock/computemocks/instance_service_server.go index d2c7a94..1b81aa9 100644 --- a/pkg/testutil/pubapimock/mock/computemocks/instance_service_server.go +++ b/pkg/testutil/pubapimock/mock/computemocks/instance_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package computemocks diff --git a/pkg/testutil/pubapimock/mock/computemocks/zone_service_server.go b/pkg/testutil/pubapimock/mock/computemocks/zone_service_server.go index 681a4da..d288321 100644 --- a/pkg/testutil/pubapimock/mock/computemocks/zone_service_server.go +++ b/pkg/testutil/pubapimock/mock/computemocks/zone_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package computemocks diff --git a/pkg/testutil/pubapimock/mock/endpointmocks/api_endpoint_service_server.go b/pkg/testutil/pubapimock/mock/endpointmocks/api_endpoint_service_server.go index 4f0d05c..3fd30ad 100644 --- a/pkg/testutil/pubapimock/mock/endpointmocks/api_endpoint_service_server.go +++ b/pkg/testutil/pubapimock/mock/endpointmocks/api_endpoint_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package endpointmocks diff --git a/pkg/testutil/pubapimock/mock/iammocks/iam_token_service_server.go b/pkg/testutil/pubapimock/mock/iammocks/iam_token_service_server.go index dbecb77..3a8706e 100644 --- a/pkg/testutil/pubapimock/mock/iammocks/iam_token_service_server.go +++ b/pkg/testutil/pubapimock/mock/iammocks/iam_token_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package iammocks diff --git a/pkg/testutil/pubapimock/mock/iammocks/service_account_service_server.go b/pkg/testutil/pubapimock/mock/iammocks/service_account_service_server.go index 6662024..cca43d9 100644 --- a/pkg/testutil/pubapimock/mock/iammocks/service_account_service_server.go +++ b/pkg/testutil/pubapimock/mock/iammocks/service_account_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package iammocks diff --git a/pkg/testutil/pubapimock/mock/resourcemanagermocks/cloud_service_server.go b/pkg/testutil/pubapimock/mock/resourcemanagermocks/cloud_service_server.go index 3f0f5b9..01369a5 100644 --- a/pkg/testutil/pubapimock/mock/resourcemanagermocks/cloud_service_server.go +++ b/pkg/testutil/pubapimock/mock/resourcemanagermocks/cloud_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package resourcemanagermocks diff --git a/pkg/testutil/pubapimock/mock/resourcemanagermocks/folder_service_server.go b/pkg/testutil/pubapimock/mock/resourcemanagermocks/folder_service_server.go index d5aa9a8..c5efc85 100644 --- a/pkg/testutil/pubapimock/mock/resourcemanagermocks/folder_service_server.go +++ b/pkg/testutil/pubapimock/mock/resourcemanagermocks/folder_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package resourcemanagermocks