helper

package
v19.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package helper (imported as testautocore_helper) provides low-level SQL assertions and mutations used by autocore tests. It deliberately imports nothing from internal/autocore or internal/autocore/persistence so it can be used from the in-package (package autocore / package persistence) tests without creating an import cycle. IDs, shard ids and states are therefore accepted as generic types constrained to their underlying kinds via the named constraints in constraints.go, so callers can pass real typed values without a cast.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivityTaskExists

func ActivityTaskExists[S shardID, W workflowID, A activityTaskID](tb testing.TB, db DB, shardID S, workflowID W, activityTaskID A) bool

ActivityTaskExists reports whether an activity_task row exists for the given shard, workflow and activity task id.

func ActivityTaskState

func ActivityTaskState[S shardID, A activityTaskID](tb testing.TB, db DB, shardID S, activityTaskID A) int16

ActivityTaskState returns the activity_task_state of the activity task addressed by shard and activity task id.

func BackdateScheduledTasks

func BackdateScheduledTasks[S shardID, W workflowID](tb testing.TB, db DB, shardID S, workflowID W)

BackdateScheduledTasks moves every scheduled_task for the workflow into the past so its due timers fire on the next scan.

func BackdateWorkflowUpdatedAt

func BackdateWorkflowUpdatedAt[W workflowID](tb testing.TB, db DB, workflowID W, at time.Time)

BackdateWorkflowUpdatedAt sets the workflow's updated_at to at, used to age a workflow past a retirement/drain window. Callers pass an absolute time, e.g. time.Now().Add(-120 * 24 * time.Hour).

func BumpShardFence

func BumpShardFence[S shardID](tb testing.TB, db DB, shardID S)

BumpShardFence increments the shard's fence_id, simulating another instance having re-claimed it.

func CountActivityTasks

func CountActivityTasks[S shardID, W workflowID](tb testing.TB, db DB, shardID S, workflowID W) int

CountActivityTasks returns the number of activity_task rows for the workflow.

func CountActivityTasksInState

func CountActivityTasksInState[S shardID, W workflowID, St state](tb testing.TB, db DB, shardID S, workflowID W, state St) int

CountActivityTasksInState returns the number of activity_task rows for the workflow in the given state.

func CountHistoryEvents

func CountHistoryEvents[S shardID, W workflowID](tb testing.TB, db DB, shardID S, workflowID W) int

CountHistoryEvents returns the number of history_event rows for the workflow.

func CountScheduledTasks

func CountScheduledTasks[S shardID, W workflowID](tb testing.TB, db DB, shardID S, workflowID W) int

CountScheduledTasks returns the number of scheduled_task rows for the workflow.

func CountSignals

func CountSignals[W workflowID](tb testing.TB, db DB, workflowID W) int

CountSignals returns the number of signal_inbox rows for the workflow.

func CountWorkflowExecutions

func CountWorkflowExecutions[W workflowID](tb testing.TB, db DB, workflowID W) int

CountWorkflowExecutions returns the number of workflow_execution rows with the given workflow id (across all shards).

func CountWorkflowTasks

func CountWorkflowTasks[S shardID, W workflowID](tb testing.TB, db DB, shardID S, workflowID W) int

CountWorkflowTasks returns the number of workflow_task rows for the workflow.

func CountWorkflowTasksInState

func CountWorkflowTasksInState[S shardID, W workflowID, St state](tb testing.TB, db DB, shardID S, workflowID W, state St) int

CountWorkflowTasksInState returns the number of workflow_task rows for the workflow in the given state.

func ExpireShardLease

func ExpireShardLease[S shardID](tb testing.TB, db DB, shardID S)

ExpireShardLease backdates the shard's lease expiry to the epoch, simulating a timed-out lease.

func PartitionAttached

func PartitionAttached(tb testing.TB, db DB, relname string) bool

PartitionAttached reports whether the named relation is currently attached as a partition to a parent table.

func RequireActivityTaskState

func RequireActivityTaskState[S shardID, A activityTaskID, St state](tb testing.TB, db DB, shardID S, activityTaskID A, want St)

RequireActivityTaskState asserts the activity task is in the given state.

func RequireExecutionState

func RequireExecutionState[S shardID, W workflowID, St state](tb testing.TB, db DB, shardID S, workflowID W, want St)

RequireExecutionState asserts the workflow is currently in the given state.

func RequireExecutionStateEventually

func RequireExecutionStateEventually[S shardID, W workflowID, St state](tb testing.TB, db DB, shardID S, workflowID W, want St)

RequireExecutionStateEventually polls until the workflow reaches the given state, treating a missing row as "not created yet".

func RequireWorkflowTaskState

func RequireWorkflowTaskState[S shardID, W workflowID, T workflowTaskID, St state](tb testing.TB, db DB, shardID S, workflowID W, workflowTaskID T, want St)

RequireWorkflowTaskState asserts the workflow task is in the given state.

func SetShardLeaseState

func SetShardLeaseState[S shardID, St state](tb testing.TB, db DB, shardID S, state St)

SetShardLeaseState sets the shard's lifecycle state.

func SetWorkflowExecutionState

func SetWorkflowExecutionState[S shardID, W workflowID, St state](tb testing.TB, db DB, shardID S, workflowID W, state St)

SetWorkflowExecutionState forces the workflow into the given execution state.

func TableExists

func TableExists(tb testing.TB, db DB, relname string) bool

TableExists reports whether a relation with the given name exists, whether or not it is currently attached as a partition.

func WorkflowExecutionState

func WorkflowExecutionState[S shardID, W workflowID](tb testing.TB, db DB, shardID S, workflowID W) int16

WorkflowExecutionState returns the current workflow_execution_state of the workflow. Fails the test if no row exists.

func WorkflowTaskExists

func WorkflowTaskExists[S shardID, W workflowID, T workflowTaskID](tb testing.TB, db DB, shardID S, workflowID W, workflowTaskID T) bool

WorkflowTaskExists reports whether a workflow_task row exists for the given shard, workflow and workflow task id.

func WorkflowTaskState

func WorkflowTaskState[S shardID, W workflowID, T workflowTaskID](tb testing.TB, db DB, shardID S, workflowID W, workflowTaskID T) int16

WorkflowTaskState returns the workflow_task_state of the workflow task addressed by shard, workflow and workflow task id.

Types

type DB

type DB interface {
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
}

Jump to

Keyboard shortcuts

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