name: test description: Run onepixel unit and e2e tests with correct env setup, coverage artifacts, and troubleshooting guidance for GeoIP/network-related failures.
Test Skill
Use this skill for unit tests, e2e tests, targeted test runs, and test triage.
Quick commands
- Full unit suite:
make test_unit
- Full e2e suite:
make test_e2e
- Full test pipeline:
make test
- Targeted package tests (fast feedback):
ENV=test go test -count 1 ./src/security/...ENV=test go test -count 1 ./src/controllers/...
- Single e2e test:
ENV=test go test -count 1 ./tests/e2e -run TestRegisterUser
Current Makefile test behavior
Defined in Makefile at repo root:
test_clean- removes
app.db,events.db,events.db.wal
- removes
test_unit(depends ontest_clean)- removes
coverage.unit.out - runs:
ENV=test go test -count 1 -timeout 10s -race -coverprofile=coverage.unit.out -covermode=atomic -v -coverpkg=./src/... ./src/...
- removes
test_e2e(depends ontest_clean)- removes
coverage.e2e.out - runs:
ENV=test go test -count 1 -timeout 10s -race -coverprofile=coverage.e2e.out -covermode=atomic -v -coverpkg=./src/... ./tests/...
- removes
test- runs
test_unitthentest_e2e
- runs
Environment mechanics to remember
ENV=testtriggerssrc/config/env.gologic:- changes cwd to repo root
- loads
onepixel.test.env - then loads
onepixel.local.envas fallback defaults
onepixel.test.envsets sqlite/duckdb dialects.USE_FILE_DBcomes from fallback local env by default (trueinonepixel.local.env).
GeoIP/network caveat (important)
db.GetGeoIPDB() checks ./GeoLite2-City.mmdb freshness (30 days). If stale/missing, it downloads from:
https://git.io/GeoLite2-City.mmdb
In restricted/offline environments, tests touching GeoIP can fail due to network/DNS.
Mitigation before running tests:
curl -L https://git.io/GeoLite2-City.mmdb -o GeoLite2-City.mmdb
Recommended agent workflow
- Run targeted tests for changed packages first.
- Run
make test_unit. - Run
make test_e2ewhen API/integration behavior changed. - Use
make testbefore final handoff when feasible.
Troubleshooting notes
- If tests time out, remember Makefile uses
-timeout 10s; for debugging, rerun failing package with a longer timeout manually. - If local env has been modified to non-file DB settings, tests may accidentally try postgres/clickhouse; restore test-friendly env values.
- Coverage artifacts are written to:
coverage.unit.outcoverage.e2e.out