Help us shape the future of Go! Take the 2026 Go Developer Survey

storetest

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package storetest holds fixtures for tests that run against the controller store.

Index

Constants

This section is empty.

Variables

View Source
var V2MappingsDDL = []string{
	`create table namespaces (
	  id                    integer             primary key,
	  token                 varchar(64)         not null,
	  name                  varchar(255)        not null,
	  description           text,
	  open                  boolean             not null default(false),
	  created_at            datetime            not null default(current_timestamp),
	  updated_at            datetime            not null default(current_timestamp),
	  deleted               boolean             not null default(false),
	  constraint chk_name check (name <> '')
	)`,
	`create table names (
	  id                    integer             primary key,
	  namespace_id          integer             not null constraint fk_names_namespaces references namespaces on delete cascade,
	  account_id            integer             not null constraint fk_names_accounts references accounts on delete cascade,
	  name                  varchar(255)        not null,
	  reserved              boolean             not null default(false),
	  created_at            datetime            not null default(current_timestamp),
	  updated_at            datetime            not null default(current_timestamp),
	  deleted               boolean             not null default(false),
	  constraint chk_name check (name <> '')
	)`,
	`create unique index uk_names on names(namespace_id, name) where not deleted`,
	`create table share_name_mappings (
	  id                    integer             primary key,
	  share_id              integer             not null constraint fk_share_name_mappings_shares references shares on delete cascade,
	  name_id               integer             not null constraint fk_share_name_mappings_names references names on delete cascade,
	  created_at            datetime            not null default(current_timestamp),
	  updated_at            datetime            not null default(current_timestamp),
	  deleted               boolean             not null default(false)
	)`,
	`create unique index uk_share_name_mappings_name on share_name_mappings(name_id) where not deleted`,
	`create table frontend_mappings (
	  id                      integer             primary key autoincrement,
	  frontend_token          string              not null,
	  name                    string              not null,
	  share_token             string              not null,
	  created_at              datetime            not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
	  unique (frontend_token, name)
	)`,
	`create index frontend_mappings_share_token_idx on frontend_mappings (share_token)`,
}

V2MappingsDDL creates the v2 line's name and frontend mapping tables, as the v2 sqlite migrations (034_v2_0_0_namespaces.sql, 037_v2_0_0_frontend_mappings.sql) define them, in a v1-migrated sqlite store.

Functions

func CreateV2Tables

func CreateV2Tables(trx *sqlx.Tx) error

CreateV2Tables runs V2MappingsDDL in the transaction.

func LiveMappings

func LiveMappings(trx *sqlx.Tx, shrId int, shrToken string) (names int, frontends int, err error)

LiveMappings counts the share's live name mappings and the frontend mappings carrying its token.

func NameDeleted

func NameDeleted(trx *sqlx.Tx, nameId int) (bool, error)

NameDeleted reports whether the name row is soft-deleted.

Types

type V2Fixture

type V2Fixture struct {
	ReservedNameId int
	AutoNameId     int
}

V2Fixture is a share published under a reserved and an auto-allocated name, with frontend mappings for its token.

func MapShare

func MapShare(trx *sqlx.Tx, acctId, shrId int, shrToken, prefix string) (*V2Fixture, error)

MapShare creates a namespace, a reserved and an auto-allocated name mapped to the share, and two frontend mappings carrying the share token.

Jump to

Keyboard shortcuts

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