Skip to content

Commit

Permalink
Merge pull request #3863 from Azure/kimorris27/ARO-4360-move-to-uber-…
Browse files Browse the repository at this point in the history
…mock-fork

Move to Uber mock/mockgen fork
  • Loading branch information
hlipsig authored Sep 26, 2024
2 parents 7859644 + 7448b3d commit e985b50
Show file tree
Hide file tree
Showing 210 changed files with 907 additions and 2,147 deletions.
6 changes: 3 additions & 3 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ $(GOTESTSUM): $(BINGO_DIR)/gotestsum.mod
@echo "(re)installing $(GOBIN)/gotestsum-v1.11.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=gotestsum.mod -o=$(GOBIN)/gotestsum-v1.11.0 "gotest.tools/gotestsum"

MOCKGEN := $(GOBIN)/mockgen-v1.6.0
MOCKGEN := $(GOBIN)/mockgen-v0.4.0
$(MOCKGEN): $(BINGO_DIR)/mockgen.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/mockgen-v1.6.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=mockgen.mod -o=$(GOBIN)/mockgen-v1.6.0 "github.com/golang/mock/mockgen"
@echo "(re)installing $(GOBIN)/mockgen-v0.4.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=mockgen.mod -o=$(GOBIN)/mockgen-v0.4.0 "go.uber.org/mock/mockgen"

4 changes: 2 additions & 2 deletions .bingo/mockgen.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.21
go 1.21.13

require github.com/golang/mock v1.6.0 // mockgen
require go.uber.org/mock v0.4.0 // mockgen
37 changes: 8 additions & 29 deletions .bingo/mockgen.sum
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
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/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
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-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
2 changes: 1 addition & 1 deletion .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.59.1"

GOTESTSUM="${GOBIN}/gotestsum-v1.11.0"

MOCKGEN="${GOBIN}/mockgen-v1.6.0"
MOCKGEN="${GOBIN}/mockgen-v0.4.0"

6 changes: 3 additions & 3 deletions .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
ci-from-docker:
runs-on: ubuntu-latest
container:
image: registry.access.redhat.com/ubi8/go-toolset:1.21.11-1.1720406008
image: registry.access.redhat.com/ubi8/go-toolset:1.21.13-1
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -32,7 +32,7 @@ jobs:
vendor-check:
runs-on: ubuntu-latest
container:
image: registry.access.redhat.com/ubi8/go-toolset:1.21.11-1.1720406008
image: registry.access.redhat.com/ubi8/go-toolset:1.21.13-1
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -46,7 +46,7 @@ jobs:
generate-check:
runs-on: ubuntu-latest
container:
image: registry.access.redhat.com/ubi8/go-toolset:1.21.11-1.1720406008
image: registry.access.redhat.com/ubi8/go-toolset:1.21.13-1
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/clean-subscription.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ parameters:
resources:
containers:
- container: golang
image: registry.access.redhat.com/ubi8/go-toolset:1.21.11-1.1720406008
image: registry.access.redhat.com/ubi8/go-toolset:1.21.13-1
options: --user=0

variables:
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/onebranch/pipeline.buildrp.official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pr: none
variables:
Cdp_Definition_Build_Count: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
ONEBRANCH_AME_ACR_LOGIN: cdpxb8e9ef87cd634085ab141c637806568c00.azurecr.io
LinuxContainerImage: $(ONEBRANCH_AME_ACR_LOGIN)/b8e9ef87-cd63-4085-ab14-1c637806568c/official/ubi8/go-toolset:1.21.11-1.1720406008 # Docker image which is used to build the project https://aka.ms/obpipelines/containers
LinuxContainerImage: $(ONEBRANCH_AME_ACR_LOGIN)/b8e9ef87-cd63-4085-ab14-1c637806568c/official/ubi8/go-toolset:1.21.13-1 # Docker image which is used to build the project https://aka.ms/obpipelines/containers
Debian_Frontend: noninteractive

resources:
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/onebranch/pipeline.buildrp.pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pr: none
variables:
Cdp_Definition_Build_Count: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
ONEBRANCH_AME_ACR_LOGIN: cdpxb8e9ef87cd634085ab141c637806568c00.azurecr.io
LinuxContainerImage: $(ONEBRANCH_AME_ACR_LOGIN)/b8e9ef87-cd63-4085-ab14-1c637806568c/official/ubi8/go-toolset:1.21.11-1.1720406008 # Docker image which is used to build the project https://aka.ms/obpipelines/containers
LinuxContainerImage: $(ONEBRANCH_AME_ACR_LOGIN)/b8e9ef87-cd63-4085-ab14-1c637806568c/official/ubi8/go-toolset:1.21.13-1 # Docker image which is used to build the project https://aka.ms/obpipelines/containers
Debian_Frontend: noninteractive

resources:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.aro-e2e
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Uses a multi-stage container build to build the RP & E2E components.
#
ARG REGISTRY
FROM ${REGISTRY}/ubi8/go-toolset:1.21.11-1.1720406008 AS builder
FROM ${REGISTRY}/ubi8/go-toolset:1.21.13-1 AS builder

USER root
ENV GOPATH=/root/go
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.aro-multistage
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Uses a multi-stage container build to build the RP.
#
ARG REGISTRY
FROM ${REGISTRY}/ubi8/go-toolset:1.21.11-1.1720406008 AS builder
FROM ${REGISTRY}/ubi8/go-toolset:1.21.13-1 AS builder

USER root
ENV GOPATH=/root/go
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ci-rp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN npm run lint && npm run build
###############################################################################
# Stage 2: Compile the Golang RP code
###############################################################################
FROM ${REGISTRY}/ubi8/go-toolset:1.21.11-1.1720406008 AS builder
FROM ${REGISTRY}/ubi8/go-toolset:1.21.13-1 AS builder
ARG ARO_VERSION
LABEL aro-builder=true
USER root
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ci-tunnel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG REGISTRY
ARG ARO_VERSION

FROM ${REGISTRY}/ubi8/go-toolset:1.21.11-1.1720406008 AS builder
FROM ${REGISTRY}/ubi8/go-toolset:1.21.13-1 AS builder
ARG ARO_VERSION
USER root
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.gatekeeper
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG REGISTRY
FROM ${REGISTRY}/ubi8/go-toolset:1.21.11-1.1720406008 AS builder
FROM ${REGISTRY}/ubi8/go-toolset:1.21.13-1 AS builder
ARG GATEKEEPER_VERSION
ENV DOWNLOAD_URL=https://github.com/open-policy-agent/gatekeeper/archive/${GATEKEEPER_VERSION}.tar.gz

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.proxy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Uses a multi-stage container build to build the proxy
#
ARG REGISTRY
FROM ${REGISTRY}/ubi8/go-toolset:1.21.11-1.1720406008 AS builder
FROM ${REGISTRY}/ubi8/go-toolset:1.21.13-1 AS builder
USER root
ENV GOPATH=/root/go
RUN mkdir -p /app
Expand Down
2 changes: 1 addition & 1 deletion cmd/aro/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func mirror(ctx context.Context, log *logrus.Entry) error {
"registry.access.redhat.com/ubi8/nodejs-18:latest",

// https://catalog.redhat.com/software/containers/ubi8/go-toolset/5ce8713aac3db925c03774d1
"registry.access.redhat.com/ubi8/go-toolset:1.21.11-1.1720406008",
"registry.access.redhat.com/ubi8/go-toolset:1.21.13-1",

// https://quay.io/repository/app-sre/managed-upgrade-operator?tab=tags
// https://gitlab.cee.redhat.com/service/app-interface/-/blob/master/data/services/osd-operators/cicd/saas/saas-managed-upgrade-operator.yaml?ref_type=heads
Expand Down
2 changes: 1 addition & 1 deletion deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ package main
// Licensed under the Apache License 2.0.

import (
_ "github.com/golang/mock/mockgen/model"
_ "go.uber.org/mock/mockgen/model"
)
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ require (
github.com/go-test/deep v1.1.0
github.com/gofrs/uuid v4.4.0+incompatible
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/golang/mock v1.6.0
github.com/google/gnostic v0.5.7-v3refs
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
Expand Down Expand Up @@ -1166,7 +1165,6 @@ exclude (
// trim old golang.org/x/ and github.com/golang/ items
exclude (
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
github.com/golang/mock v1.4.4
// exclude github.com/golang/protobuf < 1.3.2 https://nvd.nist.gov/vuln/detail/CVE-2021-3121
github.com/golang/protobuf v1.0.0
github.com/golang/protobuf v1.1.1
Expand All @@ -1178,6 +1176,7 @@ exclude (
github.com/golang/protobuf v1.4.3
github.com/golang/protobuf v1.5.0
github.com/golang/protobuf v1.5.2
go.uber.org/mock v1.4.4
golang.org/x/arch v0.0.0-20180920145803-b19384d3c130
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"reflect"
"testing"

"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"go.uber.org/mock/gomock"

"github.com/Azure/ARO-RP/pkg/api"
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/openshiftcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"strings"
"testing"

"github.com/golang/mock/gomock"
"github.com/onsi/gomega"
"github.com/onsi/gomega/types"
"github.com/sirupsen/logrus"
"go.uber.org/mock/gomock"

"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/cluster"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/arooperator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"testing"

"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"go.uber.org/mock/gomock"

"github.com/Azure/ARO-RP/pkg/api"
mock_deploy "github.com/Azure/ARO-RP/pkg/util/mocks/operator/deploy"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/billing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"errors"
"testing"

"github.com/golang/mock/gomock"
"go.uber.org/mock/gomock"

"github.com/Azure/ARO-RP/pkg/api"
mock_billing "github.com/Azure/ARO-RP/pkg/util/mocks/billing"
Expand Down
6 changes: 1 addition & 5 deletions pkg/cluster/clustermsi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/Azure/msi-dataplane/pkg/dataplane/swagger"
"github.com/Azure/msi-dataplane/pkg/store"
mockkvclient "github.com/Azure/msi-dataplane/pkg/store/mock_kvclient"
deprecatedgomock "github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"go.uber.org/mock/gomock"

Expand Down Expand Up @@ -214,10 +213,7 @@ Response contained no body
controller := gomock.NewController(t)
defer controller.Finish()

deprecatedgomockController := deprecatedgomock.NewController(t)
defer deprecatedgomockController.Finish()

mockEnv := mock_env.NewMockInterface(deprecatedgomockController)
mockEnv := mock_env.NewMockInterface(controller)
if tt.envMocks != nil {
tt.envMocks(mockEnv)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/clusterserviceprincipal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
mgmtauthorization "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization"
mgmtfeatures "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/features"
"github.com/Azure/go-autorest/autorest/to"
"github.com/golang/mock/gomock"
operatorv1 "github.com/openshift/api/operator/v1"
operatorfake "github.com/openshift/client-go/operator/clientset/versioned/fake"
"github.com/sirupsen/logrus"
"go.uber.org/mock/gomock"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
33 changes: 16 additions & 17 deletions pkg/cluster/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/Azure/go-autorest/autorest/to"
"github.com/Azure/msi-dataplane/pkg/store"
mockkvclient "github.com/Azure/msi-dataplane/pkg/store/mock_kvclient"
deprecatedgomock "github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
Expand Down Expand Up @@ -58,25 +57,25 @@ func TestDeleteNic(t *testing.T) {
name: "nic is in succeeded provisioning state",
mocks: func(networkInterfaces *mock_network.MockInterfacesClient) {
nic.InterfacePropertiesFormat.ProvisioningState = mgmtnetwork.Succeeded
networkInterfaces.EXPECT().Get(deprecatedgomock.Any(), clusterRG, nicName, "").Return(nic, nil)
networkInterfaces.EXPECT().DeleteAndWait(deprecatedgomock.Any(), clusterRG, nicName).Return(nil)
networkInterfaces.EXPECT().Get(gomock.Any(), clusterRG, nicName, "").Return(nic, nil)
networkInterfaces.EXPECT().DeleteAndWait(gomock.Any(), clusterRG, nicName).Return(nil)
},
},
{
name: "nic is in failed provisioning state",
mocks: func(networkInterfaces *mock_network.MockInterfacesClient) {
nic.InterfacePropertiesFormat.ProvisioningState = mgmtnetwork.Failed
networkInterfaces.EXPECT().Get(deprecatedgomock.Any(), clusterRG, nicName, "").Return(nic, nil)
networkInterfaces.EXPECT().CreateOrUpdateAndWait(deprecatedgomock.Any(), clusterRG, nicName, nic).Return(nil)
networkInterfaces.EXPECT().DeleteAndWait(deprecatedgomock.Any(), clusterRG, nicName).Return(nil)
networkInterfaces.EXPECT().Get(gomock.Any(), clusterRG, nicName, "").Return(nic, nil)
networkInterfaces.EXPECT().CreateOrUpdateAndWait(gomock.Any(), clusterRG, nicName, nic).Return(nil)
networkInterfaces.EXPECT().DeleteAndWait(gomock.Any(), clusterRG, nicName).Return(nil)
},
},
{
name: "provisioning state is failed and CreateOrUpdateAndWait returns error",
mocks: func(networkInterfaces *mock_network.MockInterfacesClient) {
nic.InterfacePropertiesFormat.ProvisioningState = mgmtnetwork.Failed
networkInterfaces.EXPECT().Get(deprecatedgomock.Any(), clusterRG, nicName, "").Return(nic, nil)
networkInterfaces.EXPECT().CreateOrUpdateAndWait(deprecatedgomock.Any(), clusterRG, nicName, nic).Return(fmt.Errorf("Failed to update"))
networkInterfaces.EXPECT().Get(gomock.Any(), clusterRG, nicName, "").Return(nic, nil)
networkInterfaces.EXPECT().CreateOrUpdateAndWait(gomock.Any(), clusterRG, nicName, nic).Return(fmt.Errorf("Failed to update"))
},
wantErr: "Failed to update",
},
Expand All @@ -86,23 +85,23 @@ func TestDeleteNic(t *testing.T) {
notFound := autorest.DetailedError{
StatusCode: http.StatusNotFound,
}
networkInterfaces.EXPECT().Get(deprecatedgomock.Any(), clusterRG, nicName, "").Return(nic, notFound)
networkInterfaces.EXPECT().Get(gomock.Any(), clusterRG, nicName, "").Return(nic, notFound)
},
},
{
name: "DeleteAndWait returns error",
mocks: func(networkInterfaces *mock_network.MockInterfacesClient) {
nic.InterfacePropertiesFormat.ProvisioningState = mgmtnetwork.Succeeded
networkInterfaces.EXPECT().Get(deprecatedgomock.Any(), clusterRG, nicName, "").Return(nic, nil)
networkInterfaces.EXPECT().DeleteAndWait(deprecatedgomock.Any(), clusterRG, nicName).Return(fmt.Errorf("Failed to delete"))
networkInterfaces.EXPECT().Get(gomock.Any(), clusterRG, nicName, "").Return(nic, nil)
networkInterfaces.EXPECT().DeleteAndWait(gomock.Any(), clusterRG, nicName).Return(fmt.Errorf("Failed to delete"))
},
wantErr: "Failed to delete",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
controller := deprecatedgomock.NewController(t)
controller := gomock.NewController(t)
defer controller.Finish()

env := mock_env.NewMockInterface(controller)
Expand Down Expand Up @@ -189,11 +188,11 @@ func TestShouldDeleteResourceGroup(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
controller := deprecatedgomock.NewController(t)
controller := gomock.NewController(t)
defer controller.Finish()

resourceGroups := mock_features.NewMockResourceGroupsClient(controller)
resourceGroups.EXPECT().Get(deprecatedgomock.Any(), deprecatedgomock.Eq(managedRGName)).Return(tt.getResourceGroup, tt.getErr)
resourceGroups.EXPECT().Get(gomock.Any(), gomock.Eq(managedRGName)).Return(tt.getResourceGroup, tt.getErr)

m := manager{
log: logrus.NewEntry(logrus.StandardLogger()),
Expand Down Expand Up @@ -257,11 +256,11 @@ func TestDeleteResourceGroup(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
controller := deprecatedgomock.NewController(t)
controller := gomock.NewController(t)
defer controller.Finish()

resourceGroups := mock_features.NewMockResourceGroupsClient(controller)
resourceGroups.EXPECT().DeleteAndWait(deprecatedgomock.Any(), deprecatedgomock.Eq(managedRGName)).Times(1).Return(tt.deleteErr)
resourceGroups.EXPECT().DeleteAndWait(gomock.Any(), gomock.Eq(managedRGName)).Times(1).Return(tt.deleteErr)

m := manager{
log: logrus.NewEntry(logrus.StandardLogger()),
Expand Down Expand Up @@ -344,7 +343,7 @@ func TestDisconnectSecurityGroup(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
controller := deprecatedgomock.NewController(t)
controller := gomock.NewController(t)
defer controller.Finish()

securityGroups := mock_armnetwork.NewMockSecurityGroupsClient(controller)
Expand Down
Loading

0 comments on commit e985b50

Please sign in to comment.