Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test:
@go test ./...

lint:
$(eval GO_FILES := $(shell find . -type f -name '*.go'))
$(eval GO_FILES := $(shell find . -type f -name '*.go' ! -name '*.pb.go'))
@if [ "`goimports -l $(GO_FILES) | tee /dev/stderr`" ]; then \
echo "^ - Repo contains improperly formatted go files" && echo && exit 1; \
fi
Expand Down
1 change: 1 addition & 0 deletions testing/.golint_exclude
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^examples[/\]*
51 changes: 43 additions & 8 deletions testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,50 @@
#
# Makefile for testing plugin
#

PLUGIN_NAME=testing
PLUGIN_SRC=testing
GO_MODULE=goa.design/plugins/v3/testing
# Targets:
# - "gen" generates the goa files for the example services

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

.PHONY: test-example
test-example: ## Test the example
@echo "Testing example..."
@cd example && goa gen design && go test -v ./...
gen:
@cd "$(PLUGIN_DIR)/examples/calculator" && \
goa gen goa.design/plugins/v3/testing/examples/calculator/design -o "$(PLUGIN_DIR)/examples/calculator"
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
goa gen goa.design/plugins/v3/testing/examples/httpgrpc/design -o "$(PLUGIN_DIR)/examples/httpgrpc"
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
goa gen goa.design/plugins/v3/testing/examples/jsonrpc/design -o "$(PLUGIN_DIR)/examples/jsonrpc"
make example

example:
@cd "$(PLUGIN_DIR)/examples/calculator" && \
goa example goa.design/plugins/v3/testing/examples/calculator/design -o "$(PLUGIN_DIR)/examples/calculator"
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
goa example goa.design/plugins/v3/testing/examples/httpgrpc/design -o "$(PLUGIN_DIR)/examples/httpgrpc"
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
goa example goa.design/plugins/v3/testing/examples/jsonrpc/design -o "$(PLUGIN_DIR)/examples/jsonrpc"

test:
@cd "$(PLUGIN_DIR)/examples/calculator" && \
go test -v ./...
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
go test -v ./...
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
go test -v ./...

build-examples:
@cd "$(PLUGIN_DIR)/examples/calculator" && \
go build ./cmd/calculator && go build ./cmd/calculator-cli
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
go build ./cmd/test_http_grpc && go build ./cmd/test_http_grpc-cli
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
go build ./cmd/test_jsonrpc && go build ./cmd/test_jsonrpc-cli

clean:
@cd "$(PLUGIN_DIR)/examples/calculator" && \
rm -rf calculator calculator-cli
@cd "$(PLUGIN_DIR)/examples/httpgrpc" && \
rm -rf test_http_grpc test_http_grpc-cli
@cd "$(PLUGIN_DIR)/examples/jsonrpc" && \
rm -rf test_jsonrpc test_jsonrpc-cli
3 changes: 2 additions & 1 deletion testing/examples/calculator/calculator_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
)

// RuncalculatorHarness exercises the generated harness against your service
// implementation.// Call this helper from your test, passing your service implementation.
// implementation.
// Call this helper from your test, passing your service implementation.
func RunCalculatorHarness(t *testing.T, svc calculator.Service) {
t.Helper()
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
Expand Down
10 changes: 5 additions & 5 deletions testing/examples/calculator/calculator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ func TestCalculatorScenarios(t *testing.T) {
service := NewCalculator()
h := calculatortest.NewHarness(t, service)
defer h.Close()

// Load scenarios from YAML
runner, err := calculatortest.LoadScenarios("scenarios.yaml")
if err != nil {
t.Fatalf("failed to load scenarios: %v", err)
}

// Run all scenarios
runner.Run(t, h.Client)
}
Expand All @@ -34,13 +34,13 @@ func TestSpecificScenario(t *testing.T) {
service := NewCalculator()
h := calculatortest.NewHarness(t, service)
defer h.Close()

// Load scenarios
runner, err := calculatortest.LoadScenarios("scenarios.yaml")
if err != nil {
t.Fatalf("failed to load scenarios: %v", err)
}

// Run specific scenario
runner.RunNamed(t, h.Client, "division_with_validation")
}
}
2 changes: 1 addition & 1 deletion testing/examples/calculator/design/design.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ var CalculatorError = Type("CalculatorError", func() {
Field(1, "message", String, "Error message")
Field(2, "code", String, "Error code")
Required("message", "code")
})
})

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

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

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

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

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

5 changes: 3 additions & 2 deletions testing/examples/calculator/gen/calculator/client.go

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

5 changes: 3 additions & 2 deletions testing/examples/calculator/gen/calculator/endpoints.go

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

9 changes: 5 additions & 4 deletions testing/examples/calculator/gen/calculator/service.go

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

3 changes: 3 additions & 0 deletions testing/examples/calculator/gen/goa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"goa_version": "v3.26.0"
}
5 changes: 3 additions & 2 deletions testing/examples/calculator/gen/grpc/calculator/client/cli.go

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

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

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

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

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

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Code generated with goa v3.22.6, DO NOT EDIT.
// Code generated with goa, DO NOT EDIT.
//
// calculator protocol buffer definition
//
// Command:
// $ goa gen goa.design/plugins/v3/testing/examples/calculator/design
// $ goa gen goa.design/plugins/v3/testing/examples/calculator/design -o
// $(GOPATH)/src/goa.design/plugins/testing//examples/calculator

syntax = "proto3";

Expand Down

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

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

Loading
Loading