Documentation
¶
Index ¶
- Constants
- Variables
- func GetMySQLDSN(t *testing.T) string
- func GetPostgresDSN(t *testing.T) string
- func NewTestingStore(ctx context.Context, t *testing.T) *store.Store
- func NewTestingStoreWithDSN(_ context.Context, t *testing.T, driver, dsn string) *store.Store
- func StartMemosContainer(ctx context.Context, cfg MemosContainerConfig) (testcontainers.Container, error)
- func TerminateContainers()
- type MemosContainerConfig
Constants ¶
const ( // Memos container settings for migration testing. MemosDockerImage = "neosmemo/memos" StableMemosVersion = "stable" // Always points to the latest stable release )
Variables ¶
var MemosStartupWaitStrategy = wait.ForAll( wait.ForLog("(started successfully|has been started on port)").AsRegexp(), wait.ForListeningPort("5230/tcp"), ).WithDeadline(180 * time.Second)
MemosStartupWaitStrategy defines the wait strategy for Memos container startup. Uses regex to match various log message formats across versions.
Functions ¶
func GetMySQLDSN ¶ added in v0.26.0
GetMySQLDSN starts a MySQL container (if not already running) and creates a fresh database for this test.
func GetPostgresDSN ¶ added in v0.26.0
GetPostgresDSN starts a PostgreSQL container (if not already running) and creates a fresh database for this test.
func NewTestingStore ¶
NewTestingStore creates a new testing store with a fresh database. Each test gets its own isolated database:
- SQLite: new temp file per test
- MySQL/PostgreSQL: new database per test in shared container
func NewTestingStoreWithDSN ¶ added in v0.26.0
NewTestingStoreWithDSN creates a testing store connected to a specific DSN. This is useful for testing migrations on existing data.
func StartMemosContainer ¶ added in v0.26.0
func StartMemosContainer(ctx context.Context, cfg MemosContainerConfig) (testcontainers.Container, error)
StartMemosContainer starts a Memos container for migration testing. For SQLite, it mounts the dataDir to /var/opt/memos.
func TerminateContainers ¶ added in v0.26.0
func TerminateContainers()
TerminateContainers cleans up all running containers and network. This is typically called from TestMain.
Types ¶
type MemosContainerConfig ¶ added in v0.26.0
type MemosContainerConfig struct {
Version string // Memos version tag (e.g., "0.24.0")
Driver string // Database driver: sqlite, mysql, postgres
DSN string // Database DSN (for mysql/postgres)
DataDir string // Host directory to mount for SQLite data
}
MemosContainerConfig holds configuration for starting a Memos container.