Skip to content

Commit

Permalink
add mocks for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msf committed Jun 5, 2024
1 parent c14985e commit 338fbfe
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
.PHONY: all setup lint harvester test image-build image-push
.PHONY: all setup lint ingester test image-build image-push

APPLICATION := harvester
APPLICATION := ingester
GITHUB_SHA ?= HEAD
REF_TAG := $(shell echo ${GITHUB_REF_NAME} | tr -cd '[:alnum:]')
IMAGE_TAG := ${ECR_REGISTRY}/${ECR_REPOSITORY}:${REF_TAG}-$(shell git rev-parse --short "${GITHUB_SHA}")-${GITHUB_RUN_NUMBER}
TEST_TIMEOUT := 10s

all: lint test harvester
all: lint test ingester

setup: bin/golangci-lint bin/gofumpt
setup: bin/golangci-lint bin/gofumpt bin/moq
go mod download

bin/moq:
GOBIN=$(PWD)/bin go install github.com/matryer/[email protected]
bin/golangci-lint:
GOBIN=$(PWD)/bin go install github.com/golangci/golangci-lint/cmd/[email protected]
bin/gofumpt: bin
GOBIN=$(PWD)/bin go install mvdan.cc/[email protected]

harvester: lint cmd/main.go
go build -o harvester cmd/main.go
ingester: lint cmd/main.go
go build -o ingester cmd/main.go

lint: bin/golangci-lint bin/gofumpt
go fmt ./...
Expand All @@ -30,12 +32,17 @@ test:
go mod tidy
go test -timeout=$(TEST_TIMEOUT) -race -bench=. -benchmem -cover ./...

gen-mocks: bin/moq ./client/jsonrpc/ ./client/duneapi/
./bin/moq -pkg jsonrpc_mock -out ./mocks/jsonrpc/rpcnode.go ./client/jsonrpc BlockchainClient
./bin/moq -pkg duneapi_mock -out ./mocks/duneapi/client.go ./client/duneapi BlockchainIngester


image-build:
@echo "# Building harvester docker image..."
@echo "# Building ingester docker image..."
docker build -t $(APPLICATION) -f Dockerfile --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} .

image-push: image-build
@echo "# Pushing harvester docker image..."
@echo "# Pushing ingester docker image..."
docker tag $(APPLICATION) ${IMAGE_TAG}
docker push ${IMAGE_TAG}
docker rmi ${IMAGE_TAG}
76 changes: 76 additions & 0 deletions mocks/duneapi/client.go

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

157 changes: 157 additions & 0 deletions mocks/jsonrpc/rpcnode.go

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

0 comments on commit 338fbfe

Please sign in to comment.