From 218d0ae4e35ecf8cadc48e6f2e5e202ededbffc2 Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Thu, 15 Oct 2026 18:28:34 +0200 Subject: [PATCH] Use matchers --- Makefile | 27 ++++++++++++++- e2engine/account-rejection.docker.test.yml | 18 +++++----- e2engine/account-rejection.test.yml | 18 +++++----- e2engine/fraud-rejection.docker.test.yml | 8 ++--- e2engine/fraud-rejection.test.yml | 8 ++--- e2engine/payment-demo.docker.env.yml | 34 ++++++++++--------- e2engine/payment-demo.env.yml | 34 ++++++++++--------- e2engine/successful-payment.docker.test.yml | 37 +++++++++++++-------- e2engine/successful-payment.test.yml | 37 +++++++++++++-------- scripts/demo-ci.sh | 2 +- 10 files changed, 139 insertions(+), 84 deletions(-) diff --git a/Makefile b/Makefile index 7376bbc..275018f 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,29 @@ demo-cli: .PHONY: demo-ci demo-ci: - @./scripts/demo-ci.sh \ No newline at end of file + @./scripts/demo-ci.sh + +ROOT_PATH := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) +ACCOUNT_DIR := $(ROOT_PATH)account/bin +ACCOUNT_BINARY := $(ACCOUNT_DIR)/account +PAYMENT_API_DIR := $(ROOT_PATH)payment-api/bin +PAYMENT_API_BINARY := $(PAYMENT_API_DIR)/payment-api + +.PHONY: account-service +account-service: + @echo "Building account service..." + mkdir -p $(ACCOUNT_DIR) + go build -o $(ACCOUNT_BINARY) account/cmd/main.go + echo "Starting account service..." + $(ACCOUNT_BINARY) + +.PHONY: payment-api-service +payment-api-service: + @echo "Building payment API service..." + mkdir -p $(PAYMENT_API_DIR) + go build -o $(PAYMENT_API_BINARY) payment-api/cmd/main.go + echo "Starting payment API service..." + ACCOUNT_SERVICE_ADDR=localhost:8082 \ + NOTIFICATION_SERVICE_ADDR=localhost:8083 \ + FRAUD_SERVICE_URL=http://localhost:8081 \ + $(PAYMENT_API_BINARY) diff --git a/e2engine/account-rejection.docker.test.yml b/e2engine/account-rejection.docker.test.yml index a2881fb..babeb9d 100644 --- a/e2engine/account-rejection.docker.test.yml +++ b/e2engine/account-rejection.docker.test.yml @@ -14,29 +14,31 @@ spec: headers: Content-Type: - application/json - body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' expect: http: - status: 422 - body: '{"error":"payment rejected"}' + status_code: 422 + body_json: '{"error":"payment rejected"}' calls: - service_id: fraud count: 1 http: method: POST path: /check - body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' - service_id: account count: 1 grpc: service: account.v1.AccountService method: Debit - message: - account_id: acc-002 - amount: 12500 - currency: EUR + message: >- + { + "account_id": "acc-002", + "amount": 12500, + "currency": "EUR" + } - service_id: notification count: 0 diff --git a/e2engine/account-rejection.test.yml b/e2engine/account-rejection.test.yml index 0be7cf4..ac0443e 100644 --- a/e2engine/account-rejection.test.yml +++ b/e2engine/account-rejection.test.yml @@ -14,29 +14,31 @@ spec: headers: Content-Type: - application/json - body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' expect: http: - status: 422 - body: '{"error":"payment rejected"}' + status_code: 422 + body_json: '{"error":"payment rejected"}' calls: - service_id: fraud count: 1 http: method: POST path: /check - body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' - service_id: account count: 1 grpc: service: account.v1.AccountService method: Debit - message: - account_id: acc-002 - amount: 12500 - currency: EUR + message: >- + { + "account_id": "acc-002", + "amount": 12500, + "currency": "EUR" + } - service_id: notification count: 0 diff --git a/e2engine/fraud-rejection.docker.test.yml b/e2engine/fraud-rejection.docker.test.yml index cc352c9..4c63f27 100644 --- a/e2engine/fraud-rejection.docker.test.yml +++ b/e2engine/fraud-rejection.docker.test.yml @@ -14,19 +14,19 @@ spec: headers: Content-Type: - application/json - body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' expect: http: - status: 422 - body: '{"error":"payment rejected"}' + status_code: 422 + body_json: '{"error":"payment rejected"}' calls: - service_id: fraud count: 1 http: method: POST path: /check - body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' - service_id: account count: 0 diff --git a/e2engine/fraud-rejection.test.yml b/e2engine/fraud-rejection.test.yml index 2579b21..e0ba4af 100644 --- a/e2engine/fraud-rejection.test.yml +++ b/e2engine/fraud-rejection.test.yml @@ -14,19 +14,19 @@ spec: headers: Content-Type: - application/json - body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' expect: http: - status: 422 - body: '{"error":"payment rejected"}' + status_code: 422 + body_json: '{"error":"payment rejected"}' calls: - service_id: fraud count: 1 http: method: POST path: /check - body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' - service_id: account count: 0 diff --git a/e2engine/payment-demo.docker.env.yml b/e2engine/payment-demo.docker.env.yml index d872df3..5ec755f 100644 --- a/e2engine/payment-demo.docker.env.yml +++ b/e2engine/payment-demo.docker.env.yml @@ -14,40 +14,40 @@ spec: http: method: POST path: /check - body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"approved":true}' + body_json: '{"approved":true}' - when: http: method: POST path: /check - body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"approved":true}' + body_json: '{"approved":true}' - when: http: method: POST path: /check - body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"approved":false}' + body_json: '{"approved":false}' - id: account kind: grpc @@ -84,13 +84,15 @@ spec: fixtures: - when: grpc: + service: notification.v1.NotificationService method: Send - message: - account_id: acc-001 - payment_id: payment-1 - amount: 12500 - currency: EUR + message: >- + { + "account_id": "acc-001", + "payment_id": "payment-1", + "amount": 12500, + "currency": "EUR" + } then: grpc: - status: OK - message: {} \ No newline at end of file + status: OK \ No newline at end of file diff --git a/e2engine/payment-demo.env.yml b/e2engine/payment-demo.env.yml index ac61370..5782e92 100644 --- a/e2engine/payment-demo.env.yml +++ b/e2engine/payment-demo.env.yml @@ -14,40 +14,40 @@ spec: http: method: POST path: /check - body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"approved":true}' + body_json: '{"approved":true}' - when: http: method: POST path: /check - body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}' then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"approved":true}' + body_json: '{"approved":true}' - when: http: method: POST path: /check - body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}' then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"approved":false}' + body_json: '{"approved":false}' - id: account kind: grpc @@ -84,13 +84,15 @@ spec: fixtures: - when: grpc: + service: notification.v1.NotificationService method: Send - message: - account_id: acc-001 - payment_id: payment-1 - amount: 12500 - currency: EUR + message: >- + { + "account_id": "acc-001", + "payment_id": "payment-1", + "amount": 12500, + "currency": "EUR" + } then: grpc: - status: OK - message: {} \ No newline at end of file + status: OK \ No newline at end of file diff --git a/e2engine/successful-payment.docker.test.yml b/e2engine/successful-payment.docker.test.yml index 65a68c5..488242f 100644 --- a/e2engine/successful-payment.docker.test.yml +++ b/e2engine/successful-payment.docker.test.yml @@ -14,37 +14,48 @@ spec: headers: Content-Type: - application/json - body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' expect: http: - status: 201 - body: '{"paymentId":"payment-1","accountId":"acc-001","amount":12500,"currency":"EUR","status":"completed"}' + status_code: 201 + body_json: >- + { + "paymentId":"payment-1", + "accountId":"acc-001", + "amount":12500, + "currency":"EUR", + "status":"completed" + } calls: - service_id: fraud count: 1 http: method: POST path: /check - body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' - service_id: account count: 1 grpc: service: account.v1.AccountService method: Debit - message: - account_id: acc-001 - amount: 12500 - currency: EUR + message: >- + { + "account_id": "acc-001", + "amount": 12500, + "currency": "EUR" + } - service_id: notification count: 1 grpc: service: notification.v1.NotificationService method: Send - message: - account_id: acc-001 - payment_id: payment-1 - amount: 12500 - currency: EUR \ No newline at end of file + message: >- + { + "account_id": "acc-001", + "payment_id": "payment-1", + "amount": 12500, + "currency": "EUR" + } \ No newline at end of file diff --git a/e2engine/successful-payment.test.yml b/e2engine/successful-payment.test.yml index df17148..9989526 100644 --- a/e2engine/successful-payment.test.yml +++ b/e2engine/successful-payment.test.yml @@ -14,37 +14,48 @@ spec: headers: Content-Type: - application/json - body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' expect: http: - status: 201 - body: '{"paymentId":"payment-1","accountId":"acc-001","amount":12500,"currency":"EUR","status":"completed"}' + status_code: 201 + body_json: >- + { + "paymentId":"payment-1", + "accountId":"acc-001", + "amount":12500, + "currency":"EUR", + "status":"completed" + } calls: - service_id: fraud count: 1 http: method: POST path: /check - body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' + body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}' - service_id: account count: 1 grpc: service: account.v1.AccountService method: Debit - message: - account_id: acc-001 - amount: 12500 - currency: EUR + message: >- + { + "account_id": "acc-001", + "amount": 12500, + "currency": "EUR" + } - service_id: notification count: 1 grpc: service: notification.v1.NotificationService method: Send - message: - account_id: acc-001 - payment_id: payment-1 - amount: 12500 - currency: EUR \ No newline at end of file + message: >- + { + "account_id": "acc-001", + "payment_id": "payment-1", + "amount": 12500, + "currency": "EUR" + } \ No newline at end of file diff --git a/scripts/demo-ci.sh b/scripts/demo-ci.sh index c5e79cf..c4b6e3a 100755 --- a/scripts/demo-ci.sh +++ b/scripts/demo-ci.sh @@ -7,7 +7,7 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" NETWORK="e2engine-network" DATA_DIR="${ROOT_DIR}/.e2engine" -E2ENGINE_VERSION="${E2ENGINE_VERSION:-0.1.1}" +E2ENGINE_VERSION="${E2ENGINE_VERSION:-0.2.0}" E2ENGINE_IMAGE="ghcr.io/e2engine/cli:${E2ENGINE_VERSION}" ACCOUNT_BIN="${ROOT_DIR}/account/bin/account"