Skip to content

Commit edd2c89

Browse files
committed
test: add the mock_async_routine
Add the mock_async_routine so tests can be written to use the routine mock
1 parent 80821a5 commit edd2c89

File tree

4 files changed

+235
-1
lines changed

4 files changed

+235
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
APP_NAME=asyncroutinemanager
22

3+
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
4+
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
5+
LOCAL_BIN_PATH := $(PROJECT_PATH)/bin
6+
7+
export PATH := $(LOCAL_BIN_PATH):$(PATH)
8+
39
.PHONY: all build test clean
410

511
all: build
612

13+
MOCKGEN := $(LOCAL_BIN_PATH)/mockgen
14+
15+
.PHONY: mockgen-install
16+
mockgen-install:
17+
@GOBIN=$(LOCAL_BIN_PATH) go install go.uber.org/mock/[email protected] ;\
18+
19+
.PHONY: generate
20+
generate: mockgen-install
21+
go generate ./...
22+
723
build:
824
go build -o $(APP_NAME)
925

10-
test:
26+
test: generate
1127
ginkgo -r -v
1228

1329
clean:

async_routine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const (
2424
var _ AsyncRoutine = (*asyncRoutine)(nil)
2525

2626
// AsyncRoutine is the public interface for managed async routines
27+
//
28+
//go:generate mockgen -source=async_routine.go -package=async -destination=mock_async_routine.go
2729
type AsyncRoutine interface {
2830
Name() string
2931
CreatedAt() time.Time

mock_async_routine.go

Lines changed: 215 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)