Skip to content

Commit 70b1733

Browse files
authored
Fix Makefile of testint plugin (#255)
* Fix replace directives * Add go.work files * Fix Makefile of testint plugin * Ignore *.pb.go from goimports * Add .golint_exclude * make * Add testing to PLUGINS
1 parent 291922e commit 70b1733

111 files changed

Lines changed: 1230 additions & 385 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ PLUGINS=\
2525
zaplogger \
2626
zerologger \
2727
arnz \
28-
tscap
28+
tscap \
29+
testing
2930

3031
PROTOC_VERSION=27.1
3132
ifeq ($(GOOS),linux)

plugins.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test:
2121
@go test ./...
2222

2323
lint:
24-
$(eval GO_FILES := $(shell find . -type f -name '*.go'))
24+
$(eval GO_FILES := $(shell find . -type f -name '*.go' ! -name '*.pb.go'))
2525
@if [ "`goimports -l $(GO_FILES) | tee /dev/stderr`" ]; then \
2626
echo "^ - Repo contains improperly formatted go files" && echo && exit 1; \
2727
fi

testing/.golint_exclude

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
^examples[/\]*

testing/Makefile

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,50 @@
22
#
33
# Makefile for testing plugin
44
#
5-
6-
PLUGIN_NAME=testing
7-
PLUGIN_SRC=testing
8-
GO_MODULE=goa.design/plugins/v3/testing
5+
# Targets:
6+
# - "gen" generates the goa files for the example services
97

108
# Include the common plugin makefile
9+
PLUGIN_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
1110
include ../plugins.mk
1211

13-
.PHONY: test-example
14-
test-example: ## Test the example
15-
@echo "Testing example..."
16-
@cd example && goa gen design && go test -v ./...
12+
gen:
13+
@cd "$(PLUGIN_DIR)/examples/calculator" && \
14+
goa gen goa.design/plugins/v3/testing/examples/calculator/design -o "$(PLUGIN_DIR)/examples/calculator"
15+
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
16+
goa gen goa.design/plugins/v3/testing/examples/httpgrpc/design -o "$(PLUGIN_DIR)/examples/httpgrpc"
17+
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
18+
goa gen goa.design/plugins/v3/testing/examples/jsonrpc/design -o "$(PLUGIN_DIR)/examples/jsonrpc"
19+
make example
20+
21+
example:
22+
@cd "$(PLUGIN_DIR)/examples/calculator" && \
23+
goa example goa.design/plugins/v3/testing/examples/calculator/design -o "$(PLUGIN_DIR)/examples/calculator"
24+
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
25+
goa example goa.design/plugins/v3/testing/examples/httpgrpc/design -o "$(PLUGIN_DIR)/examples/httpgrpc"
26+
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
27+
goa example goa.design/plugins/v3/testing/examples/jsonrpc/design -o "$(PLUGIN_DIR)/examples/jsonrpc"
28+
29+
test:
30+
@cd "$(PLUGIN_DIR)/examples/calculator" && \
31+
go test -v ./...
32+
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
33+
go test -v ./...
34+
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
35+
go test -v ./...
36+
37+
build-examples:
38+
@cd "$(PLUGIN_DIR)/examples/calculator" && \
39+
go build ./cmd/calculator && go build ./cmd/calculator-cli
40+
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
41+
go build ./cmd/test_http_grpc && go build ./cmd/test_http_grpc-cli
42+
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
43+
go build ./cmd/test_jsonrpc && go build ./cmd/test_jsonrpc-cli
44+
45+
clean:
46+
@cd "$(PLUGIN_DIR)/examples/calculator" && \
47+
rm -rf calculator calculator-cli
48+
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
49+
rm -rf test_http_grpc test_http_grpc-cli
50+
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
51+
rm -rf test_jsonrpc test_jsonrpc-cli

testing/examples/calculator/calculator_suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
)
1212

1313
// RuncalculatorHarness exercises the generated harness against your service
14-
// implementation.// Call this helper from your test, passing your service implementation.
14+
// implementation.
15+
// Call this helper from your test, passing your service implementation.
1516
func RunCalculatorHarness(t *testing.T, svc calculator.Service) {
1617
t.Helper()
1718
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)

testing/examples/calculator/calculator_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ func TestCalculatorScenarios(t *testing.T) {
1717
service := NewCalculator()
1818
h := calculatortest.NewHarness(t, service)
1919
defer h.Close()
20-
20+
2121
// Load scenarios from YAML
2222
runner, err := calculatortest.LoadScenarios("scenarios.yaml")
2323
if err != nil {
2424
t.Fatalf("failed to load scenarios: %v", err)
2525
}
26-
26+
2727
// Run all scenarios
2828
runner.Run(t, h.Client)
2929
}
@@ -34,13 +34,13 @@ func TestSpecificScenario(t *testing.T) {
3434
service := NewCalculator()
3535
h := calculatortest.NewHarness(t, service)
3636
defer h.Close()
37-
37+
3838
// Load scenarios
3939
runner, err := calculatortest.LoadScenarios("scenarios.yaml")
4040
if err != nil {
4141
t.Fatalf("failed to load scenarios: %v", err)
4242
}
43-
43+
4444
// Run specific scenario
4545
runner.RunNamed(t, h.Client, "division_with_validation")
46-
}
46+
}

testing/examples/calculator/design/design.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ var CalculatorError = Type("CalculatorError", func() {
126126
Field(1, "message", String, "Error message")
127127
Field(2, "code", String, "Error code")
128128
Required("message", "code")
129-
})
129+
})

testing/examples/calculator/gen/calculator/calculatortest/client.go

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

testing/examples/calculator/gen/calculator/calculatortest/errors.go

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

testing/examples/calculator/gen/calculator/calculatortest/harness.go

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

0 commit comments

Comments
 (0)