Some checks failed
Docker Build / build-and-push-image (push) Has been cancelled
Brings the project to a TDD/BDD-friendly state — apologies for shipping Phase 1.5 + Phase 2 code-first, that violated feedback_tdd_first_bdd_required. What's added : - helpers_test.go : FakeTelegram (httptest server that records sendMessage / deleteMessage / setWebhook / etc.), miniredis bootstrap, MakeUpdate / PostWebhook helpers. The same harness simulates 'a user DMing the bot' end-to-end without hitting Telegram cloud — answer to the user question. - 43 tests covering : allowlist parsing, telegram type helpers (UserID / ChatID / Text / messageID), secret_token constant-time compare, Backoff schedule, Auth (login wrong/right/logout/TTL/nil-receiver), EchoHandler, HTTPHandler (forward / timeout / non-2xx / empty body), AuthHandler (start / auth / whoami / logout / replay defense delete), Server (bad secret 401, unknown bot 404, allowlist drop, gated bot prompt, full /auth → echo → /logout flow, healthz/readyz). - All tests pass with -race in 1.6s, no external deps (miniredis + httptest in-process). Infra : - Updated .gitea/workflows/dockerimage.yaml : new 'test' job (go vet + go test -race) gates the build-and-push-image job. CI now also runs on pull_request. - docker-compose.yml : redis + postgres for full local stack. - Makefile : test-race, compose-up/down targets. - README updated with test + local-dev sections. Refs ~/.claude/plans/pour-les-notifications-on-inherited-seal.md § Phase 2.
49 lines
1.1 KiB
Makefile
49 lines
1.1 KiB
Makefile
SHELL := /bin/bash
|
|
APP := telegram-gateway
|
|
IMAGE := gitea.arcodange.lab/arcodange/$(APP)
|
|
TAG ?= dev
|
|
|
|
.PHONY: build test test-race vet tidy run docker push setwebhook deletewebhook compose-up compose-down
|
|
|
|
build:
|
|
go build -o bin/gateway .
|
|
|
|
test:
|
|
go test ./...
|
|
|
|
test-race:
|
|
go test -race -count=1 -timeout 120s ./...
|
|
|
|
vet:
|
|
go vet ./...
|
|
|
|
tidy:
|
|
go mod tidy
|
|
|
|
# Local dev stack — Redis (auth) + Postgres (Phase 2b queue) on localhost.
|
|
compose-up:
|
|
docker compose up -d --wait
|
|
|
|
compose-down:
|
|
docker compose down -v
|
|
|
|
run: build
|
|
CONFIG_PATH=./bots.example.yaml ./bin/gateway serve
|
|
|
|
docker:
|
|
docker build -t $(IMAGE):$(TAG) .
|
|
|
|
push: docker
|
|
docker push $(IMAGE):$(TAG)
|
|
|
|
# Usage: make setwebhook SLUG=echo BASE_URL=https://tg.arcodange.fr
|
|
# BOT_<SLUG>_TOKEN and BOT_<SLUG>_SECRET must be exported in your shell.
|
|
setwebhook:
|
|
@test -n "$(SLUG)" || (echo "SLUG=<bot-slug> required" && exit 1)
|
|
@test -n "$(BASE_URL)" || (echo "BASE_URL=https://… required" && exit 1)
|
|
go run . setwebhook --slug $(SLUG) --base-url $(BASE_URL)
|
|
|
|
deletewebhook:
|
|
@test -n "$(SLUG)" || (echo "SLUG=<bot-slug> required" && exit 1)
|
|
go run . deletewebhook --slug $(SLUG)
|