Streamkit tests are behavioral, race-safe, and run against multiple storage and transport combinations.
- One behavior per test — clear name, single assertion focus.
- Arrange–Act–Assert —
requirein arrange (fail fast),assertin assert. - Race-free — always
go test -race. - Multi-backend — integration tests iterate
configurations()intest/harness_test.go.
func TestShouldProduceRecordsSuccessfullyWhenGivenValidInput(t *testing.T)
func TestShouldConcurrentProducersDetectConflict(t *testing.T)Pattern: TestShould{ExpectedBehavior}When{Condition}.
func TestShouldPeekEmptySegment(t *testing.T) {
for name, harnessFactory := range configurations() {
t.Run(name, func(t *testing.T) {
harness := harnessFactory(t)
storeID := uuid.New()
ctx := t.Context()
entry, err := harness.Client.Peek(ctx, storeID, "space", "segment")
require.NoError(t, err)
assert.Equal(t, &client.Entry{Space: "space", Segment: "segment"}, entry)
})
}
}| Key | Storage factory | Transport |
|---|---|---|
inproc |
Pebble temp | inprockit |
pebble |
Pebble temp | wskit + httptest JWT |
azure |
Fazure tables | wskit + httptest JWT |
Use test/setup_data.go helpers: generateRange, setupConsumerData, TestHarness.
| Variable | Effect |
|---|---|
STREAMKIT_TEST_NO_JITTER=1 |
Set in test/testmain.go — deterministic reconnect timing |
STREAMKIT_TEST_SMALL=1 |
Smaller integration scenarios where supported |
STREAMKIT_SOAK=1 |
Enable WebSocket chaos soak (local only) |
STREAMKIT_SOAK_DURATION |
Soak duration (e.g. 90s) |
# All packages
go test -race ./...
# Integration package only
go test -race -v ./test/...
# Single test
go test -race -run TestShouldProduceRecordsSuccessfullyWhenGivenValidInput ./test/...
# Package unit tests
go test -race ./pkg/client/...
# Benchmarks
go test -bench=. -benchmem ./internal/codec/...Azure configuration requires Fazure: docker compose up -d.
github.com/stretchr/testify/require— setup and fatal preconditionsgithub.com/stretchr/testify/assert— outcome checks
Prefer table-driven subtests for input variations.
- Unit tests in the implementing package where logic is isolated.
- Integration test in
test/loopingconfigurations(). - If behavior differs by backend, assert accordingly or skip with
t.Skipand a clear message.
Place in *_bench_test.go next to the optimized code (internal/codec, inprockit, wskit). Report with -benchmem when comparing allocations.
- All tests pass with
-race golangci-lintper.golangci.yml- No new data races or flaky timing (use
STREAMKIT_TEST_NO_JITTERin test main)
For contribution workflow, see CONTRIBUTING.