assertdb

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

assertdb is a helper for testing package. It seeds/asserts the database with the data from the specified YAML file.

It assumes the yaml is in embed.FS

//go:embed dataset/*
var dataSet embed.FS

func TestUsage(t *testing.T) {
    assertdb.SeedDataSet(t, "sqlite://file:database.db", dataSet, "initial.yaml", nil)

    // some logic that modifies the database

    assertdb.AssertDB(t, "sqlite://file:database.db", dataSet, "expect.yaml", nil)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDB

func AssertDB(t *testing.T, dbConn string, folder fs.FS, fileName string, opt *dbtestify.AssertOpt)

AssertDB asserts the database state against the data from the specified YAML file.

func SeedDataSet

func SeedDataSet(t *testing.T, dbConn string, folder fs.FS, fileName string, opt *dbtestify.SeedOpt)

SeedDataSet seeds the database with the data from the specified YAML file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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