test(handlers): integration tests + recording bot + emulator on CI

Phase 5 of the 2026-05-09 review remediation plan. Closes the
handler-layer test gap (5 modules at 0% coverage in the audit) and
ends the storage-package's CI t.Skip on Firestore emulator tests.

- internal/testutil: Update fixture builders (NewPrivateMessage,
  NewGroupMessage, NewSupergroupMessage, NewChannelMessage) plus a
  RecordingBot that wraps the real go-telegram/bot.Bot with an
  httptest server. The bot library hits the test server instead of
  Telegram; multipart form fields are captured per call. Tests assert
  on Sent() / LastSent() / AssertSentText().
- Handler tests added: misc (4), util (7), wordle (10), loldle (9),
  loldleemoji (8). Cover happy paths, error paths, auth gates,
  group-vs-private subject keying, KV side effects.
- Coverage 44.7% -> 69.8% (verified via -coverprofile). All packages
  now report coverage in CI output.
- CI: ci.yml installs cloud-firestore-emulator beta component and
  starts it on localhost:8090 before go test. Sets
  FIRESTORE_EMULATOR_HOST + GOOGLE_CLOUD_PROJECT env so the storage
  package's emulator-gated tests execute instead of skipping.

go test -race -count=1 ./... clean across all 15 packages locally.
This commit is contained in:
2026-05-09 16:19:38 +07:00
parent 6368bc80ce
commit b3dea5fe21
11 changed files with 1054 additions and 9 deletions
+31 -1
View File
@@ -26,8 +26,38 @@ jobs:
- name: go vet
run: go vet ./...
# Start the Firestore emulator before tests so the storage package's
# FIRESTORE_EMULATOR_HOST-gated tests run instead of t.Skip-ing.
# gcloud is pre-installed on ubuntu-latest runners; the emulator is
# an optional component fetched on first start.
- name: start firestore emulator
run: |
gcloud --quiet components install beta cloud-firestore-emulator || true
nohup gcloud beta emulators firestore start \
--host-port=localhost:8090 \
--quiet > /tmp/firestore.log 2>&1 &
# Wait up to 60s for the emulator to bind.
for i in $(seq 1 60); do
if nc -z localhost 8090; then
echo "firestore emulator ready"
exit 0
fi
sleep 1
done
echo "firestore emulator failed to start"
cat /tmp/firestore.log
exit 1
- name: go test
run: go test -race -count=1 ./...
env:
FIRESTORE_EMULATOR_HOST: localhost:8090
GOOGLE_CLOUD_PROJECT: ci-test-project
# Keep test logs out of stdout to avoid drowning real failures.
LOG_LEVEL: error
run: go test -race -count=1 -coverprofile=cov.out ./...
- name: coverage summary
run: go tool cover -func=cov.out | tail -1
- name: go build
run: go build ./...