testutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package testutil provides shared test utilities for Melange integration tests.

Package testutil provides shared test utilities for Melange integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checker

func Checker(db *sql.DB) *melange.Checker

Checker returns a new Checker connected to the given database.

func DB

func DB(tb testing.TB) *sql.DB

DB returns a fully migrated database connection for testing. Each call creates a new isolated database copied from the template. The database is automatically cleaned up when the test completes. Works with both *testing.T and *testing.B.

func DomainTablesSQL

func DomainTablesSQL() string

DomainTablesSQL returns the embedded SQL for creating domain tables.

func EmptyDB

func EmptyDB(tb testing.TB) *sql.DB

EmptyDB returns an empty database connection for testing. Each call creates a new isolated empty database. The database is automatically cleaned up when the test completes. Works with both *testing.T and *testing.B.

func SchemaFGA

func SchemaFGA() string

SchemaFGA returns the embedded FGA schema used for tests.

func TuplesViewSQL

func TuplesViewSQL() string

TuplesViewSQL returns the embedded SQL for creating the tuples view.

Types

type Fixtures

type Fixtures struct {
	// contains filtered or unexported fields
}

Fixtures provides factory functions for creating test data in bulk. All functions use batch inserts for efficiency at scale.

func NewFixtures

func NewFixtures(ctx context.Context, db *sql.DB) *Fixtures

NewFixtures creates a new Fixtures instance for bulk data insertion.

func (*Fixtures) AddOrganizationMembers

func (f *Fixtures) AddOrganizationMembers(orgID int64, userIDs []int64, role string) error

AddOrganizationMembers adds users to an organization with the specified role. role must be one of: owner, admin, member, billing_manager

func (*Fixtures) AddRepositoryCollaborators

func (f *Fixtures) AddRepositoryCollaborators(repoID int64, userIDs []int64, role string) error

AddRepositoryCollaborators adds users as collaborators to a repository. role must be one of: owner, admin, maintainer, writer, reader

func (*Fixtures) AddTeamMembers

func (f *Fixtures) AddTeamMembers(teamID int64, userIDs []int64, role string) error

AddTeamMembers adds users to a team with the specified role. role must be one of: maintainer, member

func (*Fixtures) CreateIssues

func (f *Fixtures) CreateIssues(repoID int64, authorIDs []int64, n int) ([]int64, error)

CreateIssues creates issues in the given repository. Cycles through authorIDs for each issue.

func (*Fixtures) CreateOrganization

func (f *Fixtures) CreateOrganization(name string) (int64, error)

CreateOrganization creates a single organization and returns its ID.

func (*Fixtures) CreateOrganizations

func (f *Fixtures) CreateOrganizations(n int) ([]int64, error)

CreateOrganizations creates n organizations and returns their IDs.

func (*Fixtures) CreatePullRequests

func (f *Fixtures) CreatePullRequests(repoID int64, authorIDs []int64, n int) ([]int64, error)

CreatePullRequests creates pull requests in the given repository. Cycles through authorIDs for each PR.

func (*Fixtures) CreateRepositories

func (f *Fixtures) CreateRepositories(orgID int64, n int) ([]int64, error)

CreateRepositories creates n repositories under an organization and returns their IDs.

func (*Fixtures) CreateTeams

func (f *Fixtures) CreateTeams(orgID int64, n int) ([]int64, error)

CreateTeams creates n teams in an organization and returns their IDs.

func (*Fixtures) CreateUsers

func (f *Fixtures) CreateUsers(n int) ([]int64, error)

CreateUsers creates n users and returns their IDs.

func (*Fixtures) TupleCount

func (f *Fixtures) TupleCount() (int, error)

TupleCount returns the current count of tuples in the melange_tuples view.

Jump to

Keyboard shortcuts

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