tests

package
v0.0.0-...-0dd2db1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

Integration Tests

This directory contains integration tests for the Formbricks Hub API.

Prerequisites

Before running the tests, ensure:

  1. PostgreSQL is running (e.g. make docker-up). make docker-up starts dependency containers: PostgreSQL, the one-shot hub-migrate container, and River UI; it does not start the Hub API or worker. The tests use the connection string from .env (DATABASE_URL) when set; if empty, the default postgres://postgres:postgres@localhost:5432/test_db?sslmode=disable is used. If you set POSTGRES_PORT in .env, keep DATABASE_URL in sync.
  2. Database schema and River queue migrations have been initialized. The default make docker-up path runs them through the packaged hub-migrate container, using this checkout's migrations/ directory. If you are editing local migration files after the stack is already running, run make init-db and make river-migrate against your test database.
  3. API_KEY is set automatically by the tests; you do not need to set it.

Running Tests

Run all integration tests:

go test ./tests/... -v

Run a specific test:

go test ./tests -run TestHealthEndpoint -v

Run tests with coverage:

go test ./tests/... -v -cover

Test Structure

  • integration_test.go - Main integration tests for all API endpoints
  • helpers.go - Helper functions for test setup and cleanup

Test Coverage

The integration tests cover:

  • ✅ Health endpoint (public)
  • ✅ Create feedback records (with/without auth)
  • ✅ List feedback records (with tenant and other filters)
  • ✅ Get feedback record by ID
  • ✅ Update feedback record
  • ✅ Delete feedback record
  • ✅ Delete feedback records by user
  • ✅ Delete tenant data (feedback records, embeddings, webhooks)
  • ✅ Webhook CRUD and validation
  • ✅ Authentication middleware
  • ✅ Error handling

Test API Key

The tests use a predefined API key: test-api-key-12345

The test setup automatically sets this key in the API_KEY environment variable for authentication.

Notes

  • Tests use the actual database configured in .env
  • Tests create real data in the database
  • Consider using a separate test database for isolation
  • Semantic search is covered in handler and service tests; these integration tests focus on database-backed CRUD and webhook routes.

Documentation

Overview

Package tests provides integration test helpers and utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestData

func CleanupTestData(t *testing.T)

CleanupTestData removes test data from the database.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL