From 3b46eb49bf40e2a24b8284c0c6f09b4e3366c901 Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Fri, 20 Dec 2024 14:45:12 +0700 Subject: [PATCH] Using uber-go mock instead of golang mock in tests Signed-off-by: khanhtc1202 --- go.mod | 1 + go.sum | 2 ++ pkg/app/piped/controller/skipstage_test.go | 2 +- pkg/app/piped/executor/kubernetes/canary_test.go | 2 +- pkg/app/piped/executor/kubernetes/kubernetes_test.go | 2 +- pkg/app/piped/executor/kubernetes/primary_test.go | 2 +- pkg/app/piped/executor/kubernetes/sync_test.go | 2 +- pkg/app/server/analysisresultstore/filestore_test.go | 2 +- pkg/app/server/applicationlivestatestore/cache_test.go | 2 +- pkg/app/server/applicationlivestatestore/filestore_test.go | 2 +- pkg/app/server/grpcapi/piped_api_test.go | 2 +- pkg/app/server/grpcapi/web_api_test.go | 2 +- pkg/app/server/stagelogstore/cache_test.go | 2 +- pkg/app/server/stagelogstore/filestore_test.go | 2 +- pkg/insight/insightstore/milestonestore_test.go | 2 +- 15 files changed, 16 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index d6a4cadfd5..8c84fc1f14 100644 --- a/go.mod +++ b/go.mod @@ -52,6 +52,7 @@ require ( go.opentelemetry.io/otel/sdk v1.28.0 go.opentelemetry.io/otel/trace v1.28.0 go.uber.org/atomic v1.11.0 + go.uber.org/mock v0.5.0 go.uber.org/zap v1.19.1 golang.org/x/crypto v0.25.0 golang.org/x/mod v0.22.0 diff --git a/go.sum b/go.sum index fdcf4ca98c..d3d5632201 100644 --- a/go.sum +++ b/go.sum @@ -833,6 +833,8 @@ go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/pkg/app/piped/controller/skipstage_test.go b/pkg/app/piped/controller/skipstage_test.go index 27bb6028dc..23cd98ad06 100644 --- a/pkg/app/piped/controller/skipstage_test.go +++ b/pkg/app/piped/controller/skipstage_test.go @@ -18,8 +18,8 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/config" "github.com/pipe-cd/pipecd/pkg/git" diff --git a/pkg/app/piped/executor/kubernetes/canary_test.go b/pkg/app/piped/executor/kubernetes/canary_test.go index 1b0101270e..186881e72c 100644 --- a/pkg/app/piped/executor/kubernetes/canary_test.go +++ b/pkg/app/piped/executor/kubernetes/canary_test.go @@ -19,8 +19,8 @@ import ( "fmt" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "go.uber.org/zap" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/app/piped/executor/kubernetes/kubernetes_test.go b/pkg/app/piped/executor/kubernetes/kubernetes_test.go index d087794a8c..82fb815705 100644 --- a/pkg/app/piped/executor/kubernetes/kubernetes_test.go +++ b/pkg/app/piped/executor/kubernetes/kubernetes_test.go @@ -20,9 +20,9 @@ import ( "fmt" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/app/piped/metadatastore" provider "github.com/pipe-cd/pipecd/pkg/app/piped/platformprovider/kubernetes" diff --git a/pkg/app/piped/executor/kubernetes/primary_test.go b/pkg/app/piped/executor/kubernetes/primary_test.go index e1ce0bc32e..3564744c61 100644 --- a/pkg/app/piped/executor/kubernetes/primary_test.go +++ b/pkg/app/piped/executor/kubernetes/primary_test.go @@ -19,8 +19,8 @@ import ( "fmt" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "go.uber.org/zap" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/app/piped/executor/kubernetes/sync_test.go b/pkg/app/piped/executor/kubernetes/sync_test.go index add9ad1b31..15c7ca1a4b 100644 --- a/pkg/app/piped/executor/kubernetes/sync_test.go +++ b/pkg/app/piped/executor/kubernetes/sync_test.go @@ -21,9 +21,9 @@ import ( "path" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" "go.uber.org/zap" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/app/server/analysisresultstore/filestore_test.go b/pkg/app/server/analysisresultstore/filestore_test.go index b5c1e10973..78f03e6adc 100644 --- a/pkg/app/server/analysisresultstore/filestore_test.go +++ b/pkg/app/server/analysisresultstore/filestore_test.go @@ -18,9 +18,9 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/filestore" "github.com/pipe-cd/pipecd/pkg/filestore/filestoretest" diff --git a/pkg/app/server/applicationlivestatestore/cache_test.go b/pkg/app/server/applicationlivestatestore/cache_test.go index cee19b0c40..60bb461167 100644 --- a/pkg/app/server/applicationlivestatestore/cache_test.go +++ b/pkg/app/server/applicationlivestatestore/cache_test.go @@ -17,8 +17,8 @@ package applicationlivestatestore import ( "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/cache" "github.com/pipe-cd/pipecd/pkg/cache/cachetest" diff --git a/pkg/app/server/applicationlivestatestore/filestore_test.go b/pkg/app/server/applicationlivestatestore/filestore_test.go index 6b39e7b8e3..08fe8fcea3 100644 --- a/pkg/app/server/applicationlivestatestore/filestore_test.go +++ b/pkg/app/server/applicationlivestatestore/filestore_test.go @@ -18,8 +18,8 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/filestore" "github.com/pipe-cd/pipecd/pkg/filestore/filestoretest" diff --git a/pkg/app/server/grpcapi/piped_api_test.go b/pkg/app/server/grpcapi/piped_api_test.go index fcec8bda86..0396468829 100644 --- a/pkg/app/server/grpcapi/piped_api_test.go +++ b/pkg/app/server/grpcapi/piped_api_test.go @@ -19,8 +19,8 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/cache" "github.com/pipe-cd/pipecd/pkg/cache/cachetest" diff --git a/pkg/app/server/grpcapi/web_api_test.go b/pkg/app/server/grpcapi/web_api_test.go index ab7b4c1315..2a55ee3e7b 100644 --- a/pkg/app/server/grpcapi/web_api_test.go +++ b/pkg/app/server/grpcapi/web_api_test.go @@ -19,8 +19,8 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/cache" "github.com/pipe-cd/pipecd/pkg/cache/cachetest" diff --git a/pkg/app/server/stagelogstore/cache_test.go b/pkg/app/server/stagelogstore/cache_test.go index 2c762a96b3..8eb8a59bf5 100644 --- a/pkg/app/server/stagelogstore/cache_test.go +++ b/pkg/app/server/stagelogstore/cache_test.go @@ -17,8 +17,8 @@ package stagelogstore import ( "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/cache" "github.com/pipe-cd/pipecd/pkg/cache/cachetest" diff --git a/pkg/app/server/stagelogstore/filestore_test.go b/pkg/app/server/stagelogstore/filestore_test.go index b5ebf67f54..a3953c16ea 100644 --- a/pkg/app/server/stagelogstore/filestore_test.go +++ b/pkg/app/server/stagelogstore/filestore_test.go @@ -20,8 +20,8 @@ import ( "strings" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "github.com/pipe-cd/pipecd/pkg/filestore" "github.com/pipe-cd/pipecd/pkg/filestore/filestoretest" diff --git a/pkg/insight/insightstore/milestonestore_test.go b/pkg/insight/insightstore/milestonestore_test.go index a81c6e4cda..c735611d7d 100644 --- a/pkg/insight/insightstore/milestonestore_test.go +++ b/pkg/insight/insightstore/milestonestore_test.go @@ -18,8 +18,8 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" "go.uber.org/zap" "github.com/pipe-cd/pipecd/pkg/filestore"