mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-09-15 04:21:06 +00:00
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.
67 lines
1.8 KiB
YAML
67 lines
1.8 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
go:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
go: ['1.25']
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
cache: true
|
|
|
|
- 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
|
|
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 ./...
|
|
|
|
- name: docker build
|
|
run: docker build -t miti99bot-go .
|