Skip to content

Commit

Permalink
chore(mocks): move inside their specific packages (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
rinor authored Apr 4, 2023
1 parent 024f643 commit aaf9c72
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 15 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ post-test: do-test

test: post-test


# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# go install github.com/bufbuild/buf/cmd/buf@latest
generate:
buf generate --path ./protos/imageservice/imageservice.proto
buf generate --path ./protos/instanceservice/instanceservice.proto
Expand All @@ -49,10 +53,11 @@ run:
deps:
@GO111MODULE=on go mod download

# go install github.com/golang/mock/mockgen@latest
update-mocks:
mockgen --source=network/setup_network_interfaces.go > mock_network/setup_network_interfaces.go
mockgen --source=provider/upcloud/upcloud.go > mock_provider/mock_upcloud/upcloud.go
mockgen --source=provider/oci/oci.go > mock_provider/mock_oci/oci.go
go generate network/setup_network_interfaces.go
go generate provider/upcloud/upcloud.go
go generate provider/oci/oci.go

.PHONY: all build test clean run deps
.PHONY: pre-build do-build post-build
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions network/setup_network_interfaces.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate mockgen -source=$GOFILE -destination=$PWD/mocks/${GOFILE} -package=mocks

package network

import (
Expand Down
2 changes: 1 addition & 1 deletion network/setup_network_interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/nanovms/ops/mock_network"
"github.com/nanovms/ops/network"
mock_network "github.com/nanovms/ops/network/mocks"
)

func TestSetupNetworkInterfaces(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions mock_provider/mock_oci/oci.go → provider/oci/mocks/oci.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions provider/oci/oci.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate mockgen -source=$GOFILE -destination=$PWD/mocks/${GOFILE} -package=mocks

package oci

import (
Expand Down
2 changes: 1 addition & 1 deletion provider/oci/oci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/nanovms/ops/mock_provider/mock_oci"
"github.com/nanovms/ops/provider/oci"
mock_oci "github.com/nanovms/ops/provider/oci/mocks"
"github.com/spf13/afero"
)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions provider/upcloud/upcloud.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate mockgen -source=$GOFILE -destination=$PWD/mocks/${GOFILE} -package=mocks

package upcloud

import (
Expand Down
2 changes: 1 addition & 1 deletion provider/upcloud/upcloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/golang/mock/gomock"
"github.com/nanovms/ops/lepton"
"github.com/nanovms/ops/mock_provider/mock_upcloud"
"github.com/nanovms/ops/provider/upcloud"
mock_upcloud "github.com/nanovms/ops/provider/upcloud/mocks"
"github.com/stretchr/testify/assert"
)

Expand Down

0 comments on commit aaf9c72

Please sign in to comment.