models

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModelsForMigration added in v0.2.0

func ModelsForMigration() []interface{}

ModelsForMigration lists models in schema creation order.

func RunStartEventToTestRun added in v0.2.0

func RunStartEventToTestRun(req *events.ReportRunStartEventRequest) (*TestRun, []*Suite)

RunStartEventToTestRun maps a ReportRunStartEventRequest to a TestRun row. The returned value is ready for an idempotent upsert into the runs table.

Types

type ActiveTestStepsDocument added in v0.2.0

type ActiveTestStepsDocument struct {
	TestID         string          `bson:"test_id" json:"testId"`
	RetryIndex     int32           `bson:"retry_index" json:"retryIndex"`
	Status         string          `bson:"status,omitempty" json:"status,omitempty"`
	Steps          []*StepDocument `bson:"steps,omitempty" json:"steps,omitempty"`
	FirstEventAt   *time.Time      `bson:"first_event_at,omitempty" json:"firstEventAt,omitempty"`
	LastEventAt    *time.Time      `bson:"last_event_at,omitempty" json:"lastEventAt,omitempty"`
	FlushStartedAt *time.Time      `bson:"flush_started_at,omitempty" json:"flushStartedAt,omitempty"`
	TTLAt          *time.Time      `bson:"ttl_at,omitempty" json:"ttlAt,omitempty"`
	CreatedAt      time.Time       `bson:"created_at" json:"createdAt"`
	UpdatedAt      time.Time       `bson:"updated_at" json:"updatedAt"`
}

ActiveTestStepsDocument stores transient in-flight steps for a single active test attempt. The owning TestRunDocument keys this object by test id in ActiveTestSteps.

type Attachment added in v0.2.0

type Attachment struct {
	ID            string     `gorm:"column:id;type:text;primaryKey" json:"id"`
	RunID         string     `gorm:"column:run_id;type:text;not null;index:idx_attachments_run" json:"runId"`
	TestID        string     `gorm:"column:test_id;type:text;not null;index:idx_attachments_test" json:"testId"`
	TestAttemptID string     `gorm:"column:test_attempt_id;type:text;not null;index:idx_attachments_attempt" json:"testAttemptId"`
	StepID        *string    `gorm:"column:step_id;type:text" json:"stepId,omitempty"`
	Kind          string     `gorm:"column:kind;type:text" json:"kind,omitempty"`
	Name          string     `gorm:"column:name;type:text" json:"name,omitempty"`
	ContentType   string     `gorm:"column:content_type;type:text" json:"contentType,omitempty"`
	SizeBytes     int64      `gorm:"column:size_bytes" json:"sizeBytes,omitempty"`
	StorageKey    string     `gorm:"column:storage_key;type:text" json:"storageKey,omitempty"`
	Checksum      string     `gorm:"column:checksum;type:text" json:"checksum,omitempty"`
	CreatedAt     time.Time  `gorm:"column:created_at;autoCreateTime;index:idx_attachments_created_at" json:"createdAt"`
	DeletedAt     *time.Time `gorm:"column:deleted_at" json:"deletedAt,omitempty"`
}

Attachment maps to PostgreSQL attachments metadata.

func (Attachment) TableName added in v0.2.0

func (Attachment) TableName() string

type AttemptDocument

type AttemptDocument struct {
	RetryIndex   int32                    `bson:"retry_index" json:"retryIndex"`
	Steps        []*StepDocument          `bson:"steps,omitempty" json:"steps,omitempty"`
	Status       string                   `bson:"status,omitempty" json:"status,omitempty"`
	StartTime    *time.Time               `bson:"start_time,omitempty" json:"startTime,omitempty"`
	EndTime      *time.Time               `bson:"end_time,omitempty" json:"endTime,omitempty"`
	Duration     *int64                   `bson:"duration,omitempty" json:"duration,omitempty"`
	Attachments  []map[string]interface{} `bson:"attachments,omitempty" json:"attachments,omitempty"`
	ErrorMessage string                   `bson:"error_message,omitempty" json:"errorMessage,omitempty"`
	StackTrace   string                   `bson:"stack_trace,omitempty" json:"stackTrace,omitempty"`
	ErrorList    []string                 `bson:"error_list,omitempty" json:"errorList,omitempty"`
	Failures     []*TestFailureDocument   `bson:"failures,omitempty" json:"failures,omitempty"`
	Errors       []*TestErrorDocument     `bson:"errors,omitempty" json:"errors,omitempty"`
	StdOut       []*OutputDocument        `bson:"stdout,omitempty" json:"stdout,omitempty"`
	StdErr       []*OutputDocument        `bson:"stderr,omitempty" json:"stderr,omitempty"`
	CreatedAt    time.Time                `bson:"created_at" json:"createdAt"`
	UpdatedAt    time.Time                `bson:"updated_at" json:"updatedAt"`
}

AttemptDocument represents a single test attempt/retry. Each test can have multiple attempts based on retry_count.

type LiveStepBufferDocument added in v0.2.0

type LiveStepBufferDocument struct {
	ID             string          `bson:"_id" json:"id"`
	RunID          string          `bson:"run_id" json:"runId"`
	TestID         string          `bson:"test_id" json:"testId"`
	AttemptIndex   int32           `bson:"attempt_index" json:"attemptIndex"`
	Status         string          `bson:"status,omitempty" json:"status,omitempty"`
	Steps          []*StepDocument `bson:"steps,omitempty" json:"steps,omitempty"`
	FirstEventAt   *time.Time      `bson:"first_event_at,omitempty" json:"firstEventAt,omitempty"`
	LastEventAt    *time.Time      `bson:"last_event_at,omitempty" json:"lastEventAt,omitempty"`
	FlushStartedAt *time.Time      `bson:"flush_started_at,omitempty" json:"flushStartedAt,omitempty"`
	TTLAt          *time.Time      `bson:"ttl_at,omitempty" json:"ttlAt,omitempty"`
	CreatedAt      time.Time       `bson:"created_at" json:"createdAt"`
	UpdatedAt      time.Time       `bson:"updated_at" json:"updatedAt"`
}

LiveStepBufferDocument is the standalone collection representation of an active step buffer. The collection is initialized separately so later phases can cut over from the embedded run-document buffer without another schema hop.

type OutputDocument

type OutputDocument struct {
	Message   string     `bson:"message,omitempty" json:"message,omitempty"`
	Timestamp *time.Time `bson:"timestamp,omitempty" json:"timestamp,omitempty"`
}

OutputDocument represents stdout or stderr output

type RawMessagesRunDocument added in v0.1.1

type RawMessagesRunDocument struct {
	// RunID is the test run identifier; used as the MongoDB _id.
	RunID string `bson:"_id" json:"runId"`

	// Messages is the ordered list of raw messages received for this run.
	Messages []RetainedMessage `bson:"messages" json:"messages"`

	// CreatedAt is the time the document was first created (first message for the run).
	CreatedAt time.Time `bson:"created_at" json:"createdAt"`

	// UpdatedAt is the time the last message was appended to this document.
	UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`
}

RawMessagesRunDocument groups all retained NATS messages that belong to a single test run. The document _id is the run_id, so every message for a run is co-located in one document, making replay and audit straightforward.

type RawMessagesRunSummary added in v0.1.1

type RawMessagesRunSummary struct {
	// RunID is the retained run identifier (_id in MongoDB).
	RunID string `bson:"_id" json:"runId"`

	// MessageCount is the number of retained messages for this run.
	MessageCount int `bson:"message_count" json:"messageCount"`

	// CreatedAt is when the retention document was first created.
	CreatedAt time.Time `bson:"created_at" json:"createdAt"`

	// UpdatedAt is when the retention document was last appended to.
	UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`
}

RawMessagesRunSummary is a lightweight listing item for runs that have retained raw messages.

type RetainedMessage added in v0.1.1

type RetainedMessage struct {
	// Subject is the NATS subject on which the message was received.
	Subject string `bson:"subject" json:"subject"`

	// EventType is the decoded event type from the message envelope.
	EventType string `bson:"event_type" json:"eventType"`

	// Payload contains the parsed JSON of the full NATS message (event envelope).
	Payload map[string]interface{} `bson:"payload" json:"payload"`

	// Sequence is the JetStream sequence number of the message within the stream.
	Sequence uint64 `bson:"sequence,omitempty" json:"sequence,omitempty"`

	// Stream is the name of the JetStream stream this message was consumed from.
	Stream string `bson:"stream,omitempty" json:"stream,omitempty"`

	// ReceivedAt is the time the message was received and stored.
	ReceivedAt time.Time `bson:"received_at" json:"receivedAt"`
}

RetainedMessage is a single NATS message captured within a run's retention log. Multiple RetainedMessages are embedded in a RawMessagesRunDocument.

type RunShard added in v0.2.0

type RunShard struct {
	ID                 string     `gorm:"column:id;type:text;primaryKey" json:"id"`
	RunID              string     `` /* 151-byte string literal not displayed */
	ShardIndex         *int32     `gorm:"column:shard_index;uniqueIndex:ux_run_shards_run_id_shard_index,priority:2" json:"shardIndex,omitempty"`
	ShardCountExpected *int32     `gorm:"column:shard_count_expected" json:"shardCountExpected,omitempty"`
	Status             string     `gorm:"column:status;type:text;index:idx_run_shards_run_status,priority:2" json:"status,omitempty"`
	StartTime          *time.Time `gorm:"column:started_at" json:"startTime,omitempty"`
	EndTime            *time.Time `gorm:"column:finished_at" json:"endTime,omitempty"`
	CreatedAt          time.Time  `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
	UpdatedAt          time.Time  `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`
}

RunShard maps to the PostgreSQL run_shards table.

func RunEndEventToRunShard added in v0.2.0

func RunEndEventToRunShard(req *events.TestRunEndEventRequest) *RunShard

RunEndEventToRunShard maps run-level shard metadata in a terminal event to a RunShard row. Returns nil when the run is not sharded or shard metadata is incomplete.

func RunStartEventToRunShard added in v0.2.0

func RunStartEventToRunShard(req *events.ReportRunStartEventRequest) *RunShard

RunStartEventToRunShard maps run-level shard metadata to a RunShard row. Returns nil when the run is not sharded or shard metadata is incomplete.

func (RunShard) TableName added in v0.2.0

func (RunShard) TableName() string

type StepDocument

type StepDocument struct {
	ID            string                 `bson:"id" json:"id"`
	RunID         string                 `bson:"run_id,omitempty" json:"runId,omitempty"`
	TestCaseRunID string                 `bson:"test_case_run_id,omitempty" json:"testCaseRunId,omitempty"`
	ParentStepID  string                 `bson:"parent_step_id,omitempty" json:"parentStepId,omitempty"`
	Title         string                 `bson:"title,omitempty" json:"title,omitempty"`
	Description   string                 `bson:"description,omitempty" json:"description,omitempty"`
	StartTime     *time.Time             `bson:"start_time,omitempty" json:"startTime,omitempty"`
	Duration      *int64                 `bson:"duration,omitempty" json:"duration,omitempty"`
	Type          string                 `bson:"type,omitempty" json:"type,omitempty"`
	Metadata      map[string]interface{} `bson:"metadata,omitempty" json:"metadata,omitempty"`
	Tags          []string               `bson:"tags,omitempty" json:"tags,omitempty"`
	WorkerIndex   string                 `bson:"worker_index,omitempty" json:"workerIndex,omitempty"`
	Status        string                 `bson:"status,omitempty" json:"status,omitempty"`
	Category      string                 `bson:"category,omitempty" json:"category,omitempty"`
	Location      string                 `bson:"location,omitempty" json:"location,omitempty"`
	RetryIndex    int32                  `bson:"retry_index,omitempty" json:"retryIndex,omitempty"`

	// Error fields
	Error     string    `bson:"error,omitempty" json:"error,omitempty"`   // Single error message
	Errors    []string  `bson:"errors,omitempty" json:"errors,omitempty"` // Array of error messages
	CreatedAt time.Time `bson:"created_at" json:"createdAt"`
	UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`

	// Nested steps (for step hierarchies)
	Steps []*StepDocument `bson:"steps,omitempty" json:"steps,omitempty"`
}

StepDocument represents a test step embedded within a test or parent step.

type StepRun

type StepRun = StepDocument

Type aliases for backward compatibility with GraphQL generated code These allow the existing GraphQL schema to work with the new MongoDB document models

type Suite added in v0.2.0

type Suite struct {
	ID              string                 `gorm:"column:id;type:text;primaryKey" json:"id"`
	RunID           string                 `gorm:"column:run_id;type:text;not null;index:idx_suites_run_id;index:idx_suites_run_status,priority:1" json:"runId,omitempty"`
	ExternalSuiteID string                 `gorm:"column:external_suite_id;type:text;index:idx_suites_run_external_suite_id,priority:2" json:"externalSuiteId,omitempty"`
	ParentSuiteID   *string                `gorm:"column:parent_suite_id;type:text" json:"parentSuiteId,omitempty"`
	Name            string                 `gorm:"column:name;type:text" json:"name,omitempty"`
	Description     string                 `gorm:"column:description;type:text" json:"description,omitempty"`
	Status          string                 `gorm:"column:status;type:text;index:idx_suites_run_status,priority:2" json:"status,omitempty"`
	Metadata        map[string]interface{} `gorm:"column:metadata;type:jsonb;serializer:json" json:"metadata,omitempty"`
	Duration        *int64                 `gorm:"column:duration" json:"duration,omitempty"`
	Location        string                 `gorm:"column:location;type:text" json:"location,omitempty"`
	Type            string                 `gorm:"column:type;type:text" json:"type,omitempty"`
	TestSuiteSpecID string                 `gorm:"column:test_suite_spec_id;type:text" json:"testSuiteSpecId,omitempty"`
	InitiatedBy     string                 `gorm:"column:initiated_by;type:text" json:"initiatedBy,omitempty"`
	ProjectName     string                 `gorm:"column:project_name;type:text" json:"projectName,omitempty"`
	Author          string                 `gorm:"column:author;type:text" json:"author,omitempty"`
	Owner           string                 `gorm:"column:owner;type:text" json:"owner,omitempty"`
	TestCaseIDs     []string               `gorm:"column:test_case_ids;type:jsonb;serializer:json" json:"testCaseIds,omitempty"`
	SubSuiteIDs     []string               `gorm:"column:sub_suite_ids;type:jsonb;serializer:json" json:"subSuiteIds,omitempty"`
	Tags            []string               `gorm:"column:tags;type:jsonb;serializer:json" json:"tags,omitempty"`
	StartTime       *time.Time             `gorm:"column:started_at" json:"startTime,omitempty"`
	EndTime         *time.Time             `gorm:"column:finished_at" json:"endTime,omitempty"`
	CreatedAt       time.Time              `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
	UpdatedAt       time.Time              `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`

	Suites []Suite `gorm:"foreignKey:ParentSuiteID;references:ID" json:"suites,omitempty"`
	Tests  []Test  `gorm:"foreignKey:SuiteID;references:ID" json:"tests,omitempty"`
}

Suite maps to the PostgreSQL suites table.

func (Suite) TableName added in v0.2.0

func (Suite) TableName() string

type SuiteDocument

type SuiteDocument struct {
	ID              string                 `bson:"id" json:"id"`
	RunID           string                 `bson:"run_id,omitempty" json:"runId,omitempty"`
	ParentSuiteID   string                 `bson:"parent_suite_id,omitempty" json:"parentSuiteId,omitempty"`
	Name            string                 `bson:"name,omitempty" json:"name,omitempty"`
	Description     string                 `bson:"description,omitempty" json:"description,omitempty"`
	Status          string                 `bson:"status,omitempty" json:"status,omitempty"`
	Metadata        map[string]interface{} `bson:"metadata,omitempty" json:"metadata,omitempty"`
	Duration        *int64                 `bson:"duration,omitempty" json:"duration,omitempty"`
	Location        string                 `bson:"location,omitempty" json:"location,omitempty"`
	Type            string                 `bson:"type,omitempty" json:"type,omitempty"`
	TestSuiteSpecID string                 `bson:"test_suite_spec_id,omitempty" json:"testSuiteSpecId,omitempty"`
	InitiatedBy     string                 `bson:"initiated_by,omitempty" json:"initiatedBy,omitempty"`
	ProjectName     string                 `bson:"project_name,omitempty" json:"projectName,omitempty"`
	Author          string                 `bson:"author,omitempty" json:"author,omitempty"`
	Owner           string                 `bson:"owner,omitempty" json:"owner,omitempty"`
	TestCaseIds     []string               `bson:"test_case_ids,omitempty" json:"testCaseIds,omitempty"`
	SubSuiteIds     []string               `bson:"sub_suite_ids,omitempty" json:"subSuiteIds,omitempty"`
	TestCases       []TestDocument         `bson:"test_cases,omitempty" json:"testCases,omitempty"`
	Tags            []string               `bson:"tags,omitempty" json:"tags,omitempty"`
	StartTime       *time.Time             `bson:"start_time,omitempty" json:"startTime,omitempty"`
	EndTime         *time.Time             `bson:"end_time,omitempty" json:"endTime,omitempty"`
	CreatedAt       time.Time              `bson:"created_at" json:"createdAt"`
	UpdatedAt       time.Time              `bson:"updated_at" json:"updatedAt"`

	// Nested child suites
	Suites []*SuiteDocument `bson:"suites,omitempty" json:"suites,omitempty"`
	// Test cases within this suite
	Tests []*TestDocument `bson:"tests,omitempty" json:"tests,omitempty"`
}

SuiteDocument represents a test suite embedded within a test run document. Non-root suites are appended to their parent suite's Suites array.

type Test added in v0.2.0

type Test struct {
	ID             string                 `gorm:"column:id;type:text;primaryKey" json:"id"`
	RunID          string                 `gorm:"column:run_id;type:text;not null;index:idx_tests_run_id" json:"runId,omitempty"`
	ExternalTestID string                 `` /* 170-byte string literal not displayed */
	SuiteID        *string                `gorm:"column:suite_id;type:text;not null;index:idx_tests_suite_status,priority:1" json:"suiteId,omitempty"`
	Name           string                 `gorm:"column:name;type:text" json:"name,omitempty"`
	Title          string                 `gorm:"column:title;type:text" json:"title,omitempty"`
	Description    string                 `gorm:"column:description;type:text" json:"description,omitempty"`
	Status         string                 `gorm:"column:status;type:text;index:idx_tests_suite_status,priority:2" json:"status,omitempty"`
	StartTime      *time.Time             `gorm:"column:started_at" json:"startTime,omitempty"`
	EndTime        *time.Time             `gorm:"column:finished_at" json:"endTime,omitempty"`
	Duration       *int64                 `gorm:"column:duration" json:"duration,omitempty"`
	Metadata       map[string]interface{} `gorm:"column:metadata;type:jsonb;serializer:json" json:"metadata,omitempty"`
	Tags           []string               `gorm:"column:tags;type:jsonb;serializer:json" json:"tags,omitempty"`
	Location       string                 `gorm:"column:location;type:text" json:"location,omitempty"`
	RetryCount     *int32                 `gorm:"column:retry_count" json:"retryCount,omitempty"`
	RetryIndex     *int32                 `gorm:"column:retry_index" json:"retryIndex,omitempty"`
	Timeout        *int32                 `gorm:"column:timeout" json:"timeout,omitempty"`
	CreatedAt      time.Time              `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
	UpdatedAt      time.Time              `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`

	Attempts []TestAttempt `gorm:"foreignKey:TestID;references:ID" json:"attempts,omitempty"`
}

Test maps to the PostgreSQL tests table.

func RunStartEventToTests added in v0.2.0

func RunStartEventToTests(req *events.ReportRunStartEventRequest) []*Test

RunStartEventToTests maps embedded test cases in a run-start payload to relational test rows.

func TestCaseRunToRelationalTest added in v0.2.0

func TestCaseRunToRelationalTest(protoTest *entities.TestCaseRun) *Test

TestCaseRunToRelationalTest maps a TestCaseRun payload to the relational tests row.

func (Test) TableName added in v0.2.0

func (Test) TableName() string

type TestAttempt added in v0.2.0

type TestAttempt struct {
	ID           string     `gorm:"column:id;type:text;primaryKey" json:"id"`
	RunID        string     `gorm:"column:run_id;type:text;not null;index:idx_attempts_run_id" json:"runId,omitempty"`
	TestID       string     `` /* 151-byte string literal not displayed */
	AttemptIndex int32      `` /* 153-byte string literal not displayed */
	Status       string     `gorm:"column:status;type:text;index:idx_attempts_status_finished_at,priority:1" json:"status,omitempty"`
	StartTime    *time.Time `gorm:"column:started_at" json:"startTime,omitempty"`
	EndTime      *time.Time `gorm:"column:finished_at;index:idx_attempts_status_finished_at,priority:2" json:"endTime,omitempty"`
	Duration     *int64     `gorm:"column:duration" json:"duration,omitempty"`

	// Steps holds the step array containing step trees serialized as jsonb.
	// Go type is json.RawMessage (provisional — concrete typed decode at read time).
	Steps *json.RawMessage `gorm:"column:steps;type:jsonb" json:"steps,omitempty"`

	Attachments  []map[string]interface{} `gorm:"column:attachments;type:jsonb;serializer:json" json:"attachments,omitempty"`
	ErrorMessage string                   `gorm:"column:error_message;type:text" json:"errorMessage,omitempty"`
	StackTrace   string                   `gorm:"column:stack_trace;type:text" json:"stackTrace,omitempty"`
	ErrorList    []string                 `gorm:"column:error_list;type:jsonb;serializer:json" json:"errorList,omitempty"`
	Failures     []*TestFailureDocument   `gorm:"column:failures;type:jsonb;serializer:json" json:"failures,omitempty"`
	Errors       []*TestErrorDocument     `gorm:"column:errors;type:jsonb;serializer:json" json:"errors,omitempty"`
	StdOut       []*OutputDocument        `gorm:"column:stdout;type:jsonb;serializer:json" json:"stdout,omitempty"`
	StdErr       []*OutputDocument        `gorm:"column:stderr;type:jsonb;serializer:json" json:"stderr,omitempty"`

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`

	AttachmentsRows []Attachment `gorm:"foreignKey:TestAttemptID;references:ID" json:"attachmentsRows,omitempty"`
}

TestAttempt maps to PostgreSQL test_attempts. Steps are stored on the attempt row as requested.

func TestCaseRunToRelationalAttempt added in v0.2.0

func TestCaseRunToRelationalAttempt(protoTest *entities.TestCaseRun, attachments []map[string]interface{}) *TestAttempt

TestCaseRunToRelationalAttempt maps a TestCaseRun payload to the relational test_attempts row.

func (TestAttempt) TableName added in v0.2.0

func (TestAttempt) TableName() string

type TestCaseRun

type TestCaseRun = TestDocument

Type aliases for backward compatibility with GraphQL generated code These allow the existing GraphQL schema to work with the new MongoDB document models

type TestDocument

type TestDocument struct {
	ID          string `bson:"id" json:"id"`
	Name        string `bson:"name,omitempty" json:"name,omitempty"` // Same as Title, for protobuf compatibility
	Title       string `bson:"title,omitempty" json:"title,omitempty"`
	Description string `bson:"description,omitempty" json:"description,omitempty"`
	RunID       string `bson:"run_id,omitempty" json:"runId,omitempty"`
	SuiteID     string `bson:"suite_id,omitempty" json:"suiteId,omitempty"`

	// Status mirrors the status of attempts[retry_index]
	Status string `bson:"status,omitempty" json:"status,omitempty"`

	// StartTime is the earliest (attempt[0].start_time)
	StartTime *time.Time `bson:"start_time,omitempty" json:"startTime,omitempty"`

	// EndTime is the latest (current attempt's end_time)
	EndTime *time.Time `bson:"end_time,omitempty" json:"endTime,omitempty"`

	// Duration is from the current attempt
	Duration *int64 `bson:"duration,omitempty" json:"duration,omitempty"`

	Metadata   map[string]interface{} `bson:"metadata,omitempty" json:"metadata,omitempty"`
	Tags       []string               `bson:"tags,omitempty" json:"tags,omitempty"`
	Location   string                 `bson:"location,omitempty" json:"location,omitempty"`
	RetryCount *int32                 `bson:"retry_count,omitempty" json:"retryCount,omitempty"`

	// RetryIndex indicates which attempt is currently active
	RetryIndex *int32 `bson:"retry_index,omitempty" json:"retryIndex,omitempty"`

	Timeout *int32 `bson:"timeout,omitempty" json:"timeout,omitempty"`

	// Attempts array: sized to retry_count+1, indexed by retry_index
	Attempts []*AttemptDocument `bson:"attempts,omitempty" json:"attempts,omitempty"`

	// DEPRECATED: Legacy single error fields (for backward compatibility with older events)
	// New code should use attempts[retry_index].error_message instead
	ErrorMessage string `bson:"error_message,omitempty" json:"errorMessage,omitempty"`

	// DEPRECATED: Use attempts[retry_index].stack_trace instead
	StackTrace string `bson:"stack_trace,omitempty" json:"stackTrace,omitempty"`

	// DEPRECATED: Use attempts[retry_index].attachments instead
	Attachments []map[string]interface{} `bson:"attachments,omitempty" json:"attachments,omitempty"`

	// DEPRECATED: Use attempts[retry_index].failures instead
	Failures []*TestFailureDocument `bson:"failures,omitempty" json:"failures,omitempty"`

	// DEPRECATED: Use attempts[retry_index].errors instead
	Errors []*TestErrorDocument `bson:"errors,omitempty" json:"errors,omitempty"`

	// DEPRECATED: Use attempts[retry_index].error_list instead
	ErrorList []string `bson:"error_list,omitempty" json:"errorList,omitempty"`

	// DEPRECATED: Use attempts[retry_index].stdout instead
	StdOut []*OutputDocument `bson:"stdout,omitempty" json:"stdout,omitempty"`

	// DEPRECATED: Use attempts[retry_index].stderr instead
	StdErr []*OutputDocument `bson:"stderr,omitempty" json:"stderr,omitempty"`

	CreatedAt time.Time `bson:"created_at" json:"createdAt"`
	UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`

	// DEPRECATED: Use attempts[retry_index].steps instead
	Steps []*StepDocument `bson:"steps,omitempty" json:"steps,omitempty"`
}

TestDocument represents a test case embedded within a suite or run document. With attempt-based retries: each test has an Attempts array containing per-attempt data. Test-level Status/StartTime/EndTime/Duration represent aggregated values across attempts.

type TestErrorDocument

type TestErrorDocument struct {
	ErrorMessage string                   `bson:"error_message,omitempty" json:"errorMessage,omitempty"`
	StackTrace   string                   `bson:"stack_trace,omitempty" json:"stackTrace,omitempty"`
	Timestamp    *time.Time               `bson:"timestamp,omitempty" json:"timestamp,omitempty"`
	Attachments  []map[string]interface{} `bson:"attachments,omitempty" json:"attachments,omitempty"`
}

TestErrorDocument represents a test error with details

type TestFailureDocument

type TestFailureDocument struct {
	FailureMessage string                   `bson:"failure_message,omitempty" json:"failureMessage,omitempty"`
	StackTrace     string                   `bson:"stack_trace,omitempty" json:"stackTrace,omitempty"`
	Timestamp      *time.Time               `bson:"timestamp,omitempty" json:"timestamp,omitempty"`
	Attachments    []map[string]interface{} `bson:"attachments,omitempty" json:"attachments,omitempty"`
}

TestFailureDocument represents a test failure with details

type TestRun added in v0.2.0

type TestRun struct {
	ID          string                 `gorm:"column:id;type:text;primaryKey" json:"id"`
	Name        string                 `gorm:"column:name;type:text" json:"name,omitempty"`
	Description string                 `gorm:"column:description;type:text" json:"description,omitempty"`
	Status      string                 `gorm:"column:status;type:text;index:idx_runs_status_started_at,priority:1" json:"status,omitempty"`
	Metadata    map[string]interface{} `gorm:"column:metadata;type:jsonb;serializer:json" json:"metadata,omitempty"`
	Duration    *int64                 `gorm:"column:duration" json:"duration,omitempty"`
	TotalTests  int32                  `gorm:"column:total_tests" json:"totalTests,omitempty"`
	InitiatedBy string                 `gorm:"column:initiated_by;type:text" json:"initiatedBy,omitempty"`
	ProjectName string                 `gorm:"column:project_name;type:text" json:"projectName,omitempty"`
	StartTime   *time.Time             `gorm:"column:started_at;index:idx_runs_status_started_at,priority:2;index:idx_runs_started_at" json:"startTime,omitempty"`
	EndTime     *time.Time             `gorm:"column:finished_at" json:"endTime,omitempty"`
	CreatedAt   time.Time              `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
	UpdatedAt   time.Time              `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`

	Shards []RunShard `gorm:"foreignKey:RunID;references:ID" json:"shards,omitempty"`
	Suites []Suite    `gorm:"foreignKey:RunID;references:ID" json:"suites,omitempty"`
	Tests  []Test     `gorm:"foreignKey:RunID;references:ID" json:"tests,omitempty"`
}

TestRun maps to the PostgreSQL runs table. It intentionally mirrors TestRunDocument fields where practical.

func RunEndEventToTestRun added in v0.2.0

func RunEndEventToTestRun(req *events.TestRunEndEventRequest) TestRun

RunEndEventToTestRun maps a TestRunEndEventRequest to TestRun. The returned fields are intended for a partial update to finalize the run's terminal state.

func (TestRun) TableName added in v0.2.0

func (TestRun) TableName() string

type TestRunDocument

type TestRunDocument struct {
	ID              string                 `bson:"_id" json:"id"`
	Name            string                 `bson:"name,omitempty" json:"name,omitempty"`
	Description     string                 `bson:"description,omitempty" json:"description,omitempty"`
	Status          string                 `bson:"status,omitempty" json:"status,omitempty"`
	Metadata        map[string]interface{} `bson:"metadata,omitempty" json:"metadata,omitempty"`
	Duration        *int64                 `bson:"duration,omitempty" json:"duration,omitempty"` // Duration in nanoseconds
	TotalTests      int32                  `bson:"total_tests,omitempty" json:"totalTests,omitempty"`
	TestSuiteSpecID string                 `bson:"test_suite_spec_id,omitempty" json:"testSuiteSpecId,omitempty"`
	InitiatedBy     string                 `bson:"initiated_by,omitempty" json:"initiatedBy,omitempty"`
	ProjectName     string                 `bson:"project_name,omitempty" json:"projectName,omitempty"`
	StartTime       *time.Time             `bson:"start_time,omitempty" json:"startTime,omitempty"`
	EndTime         *time.Time             `bson:"end_time,omitempty" json:"endTime,omitempty"`
	CreatedAt       time.Time              `bson:"created_at" json:"createdAt"`
	UpdatedAt       time.Time              `bson:"updated_at" json:"updatedAt"`

	// Embedded child suites for nested suite structures
	Suites []*SuiteDocument `bson:"suites,omitempty" json:"suites,omitempty"`
	// Embedded test cases
	Tests []*TestDocument `bson:"tests,omitempty" json:"tests,omitempty"`
	// ActiveTestSteps buffers in-flight step trees by test id while the attempt is running.
	ActiveTestSteps map[string]*ActiveTestStepsDocument `bson:"active_test_steps,omitempty" json:"activeTestSteps,omitempty"`
}

TestRunDocument represents a complete test run as a single MongoDB document. This document-based structure follows the repository implementation where: - New runID creates a new test run document - Suite end updates existing suite attributes - Test begin appends to parent suite's Tests array - Test end updates test attributes - Step begin appends to parent (test or step) Steps array - Step end updates step attributes

Jump to

Keyboard shortcuts

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