Skip to content

Commit

Permalink
gateway: quick fix for mockgen Make targets (#2189)
Browse files Browse the repository at this point in the history
This fixes a chicken-and-egg problem that we hit when trying to add a
service since the package the code-generator reflects on also requires
that the generated code is already correctly generated.

Note the change in clients_mock.go is likely from the fact that this
file was hand-edited in the past.

I've also removed a Make target which simply didn't work because the
relevant files didn't exist.

Further, I noticed that running `make` produces files in

    mock_compliance_events/

which are not currently in source control. I haven't added them here
as as I wasn't sure if this was intentional.

In short, mock generation is a big mess still and needs to be cleaned
up, but at least now `make` works again.

Signed-off-by: Steven Danna <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
  • Loading branch information
stevendanna authored Nov 13, 2019
1 parent 9b6e06a commit d1a0654
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !mockgen

package gateway

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !mockgen

//
// Author:: Salim Afiune <[email protected]>
// Copyright:: Copyright 2018, Chef Software Inc.
Expand Down
7 changes: 5 additions & 2 deletions components/automate-gateway/gateway/datacollector_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !mockgen

//
// Author:: Salim Afiune <[email protected]>
// Copyright:: Copyright 2018, Chef Software Inc.
Expand All @@ -9,11 +11,12 @@ import (
"io/ioutil"
"testing"

structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/stretchr/testify/assert"

ingestProto "github.com/chef/automate/api/external/ingest/request"
subject "github.com/chef/automate/components/automate-gateway/gateway"
inspecEvent "github.com/chef/automate/components/compliance-service/ingest/events/inspec"
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/stretchr/testify/assert"
)

func readExample(path string) []byte {
Expand Down
2 changes: 2 additions & 0 deletions components/automate-gateway/gateway/helpers_internal_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !mockgen

//
// Author:: Salim Afiune <[email protected]>
// Copyright:: Copyright 2018, Chef Software Inc.
Expand Down
13 changes: 9 additions & 4 deletions components/automate-gateway/gateway_mocks/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# NOTE(ssd) 2019-11-13: The mockgen tag is used to exclude files in
# the gateway package that require the mocked client package to
# build. According to the documenation of mockgen, we should be in
# "source" mode which doesn't require compiling the module; however,
# in practice it appears to be compiling the module anyway, leading to
# a chicken-and-egg problem.

export GOFLAGS = -mod=vendor -tags=mockgen

all: mock_compliance_events/compliance_events_mock.go \
mock_compliance_ingest/compliance_ingest_mock.go \
mock_feed/feed_mock.go \
mock_gateway/clients_mock.go \
mock_notifier/notifier_mock.go

Expand All @@ -10,9 +18,6 @@ mock_compliance_events/compliance_events_mock.go: ../../compliance-service/inges
mock_compliance_ingest/compliance_ingest_mock.go: ../../compliance-service/ingest/ingest/compliance.pb.go
mockgen -source $< -destination $@ -package mock_compliance_ingest

mock_feed/feed_mock.go: ../../compliance-service/api/automate-feed/feed.pb.go
mockgen -source $< -destination $@

mock_gateway/clients_mock.go: ../gateway/clients.go
mockgen -source $< -destination $@

Expand Down

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

0 comments on commit d1a0654

Please sign in to comment.