stemedb/sdk/go/steme/integration_helpers_test.go
jordan b3e8a9a058 feat: Multi-application expansion with chaos testing and community UI
Major additions:
- Community Next.js app (port 18187) for browsing claims with API docs
- stemedb-chaos crate: Fault injection, chaos testing, CRDT properties
- Latent ingestion system: Reddit/FDA ingesters with ADK-Go agents
- Disputed claims handling: Manual review workflows and validation
- Aphoria security scanner: New extractors (SQL injection, command
  injection, weak crypto, TLS version), policy-based ignores, UAT reports
- Docker infrastructure: Dockerfile, docker-compose.yml for full stack
- VulnBank demo: Intentionally vulnerable multi-language test corpus

SDK & API enhancements:
- Source registry handlers for tracking data provenance
- Metrics endpoint
- Skeptic filtering improvements

Code quality:
- Split 14 large files (>500 lines) into focused modules
- All files now under 500-line limit per project guidelines

Documentation:
- Chaos testing guide, circuit breakers, observability docs
- Phase 7 UAT documentation updates
- Martin Kleppmann technical writer agent

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:24:14 -07:00

74 lines
1.7 KiB
Go

//go:build integration
package steme
import (
"context"
"fmt"
"os"
"testing"
"time"
)
// Integration test helpers and health check.
//
// To run these tests:
//
// 1. Start the StemeDB API server:
// cargo run --bin stemedb-api
//
// 2. Run the integration tests:
// STEMEDB_URL=http://localhost:18180 go test -tags=integration ./...
//
// These tests are skipped by default (build tag "integration") to avoid
// breaking CI when no server is running.
// getTestClient creates a client with a generated signer for testing.
//
// Skips the test if STEMEDB_URL is not set.
func getTestClient(t *testing.T) *Client {
t.Helper()
baseURL := os.Getenv("STEMEDB_URL")
if baseURL == "" {
t.Skip("STEMEDB_URL not set - skipping integration test")
}
signer, err := GenerateSigner()
if err != nil {
t.Fatalf("GenerateSigner() failed: %v", err)
}
return NewClient(baseURL, signer)
}
// uniqueSubject generates a unique subject for test isolation.
//
// This prevents tests from interfering with each other by ensuring
// each test operates on distinct subjects.
func uniqueSubject(base string) string {
return fmt.Sprintf("%s_%d", base, time.Now().UnixNano())
}
// TestIntegration_Health verifies the health endpoint works.
func TestIntegration_Health(t *testing.T) {
client := getTestClient(t)
ctx := context.Background()
health, err := client.Health(ctx)
if err != nil {
t.Fatalf("Health() failed: %v", err)
}
if health.Status != "healthy" {
t.Errorf("Health.Status = %s, want healthy", health.Status)
}
if health.Version == "" {
t.Error("Health.Version is empty")
}
t.Logf("Server status: %s, version: %s, assertions: %d",
health.Status, health.Version, health.AssertionsCount)
}