testutils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestDB

func CleanupTestDB()

func SetupTestServer

func SetupTestServer() (*gin.Engine, *gorm.DB)

setupTestServer initializes a Gin router and database for testing.

Types

type JSONMap

type JSONMap map[string]interface{}

JSONMap is a custom type that implements driver.Valuer and sql.Scanner. testutils cannot import internal/models (models tests import testutils), so it carries its own minimal copy.

func (JSONMap) GormDBDataType added in v0.5.0

func (JSONMap) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType makes the column JSON on MySQL (which has no JSONB).

func (*JSONMap) Scan

func (m *JSONMap) Scan(value interface{}) error

Scan deserializes JSON from the database.

func (JSONMap) Value

func (m JSONMap) Value() (driver.Value, error)

Value serializes the map to JSON for storage.

type UserRole

type UserRole struct {
	ID          uint    `json:"id"`
	Name        string  `json:"name"`                                   // Role name (e.g., admin, editor, viewer)
	Description string  `json:"description"`                            // Role description
	Permissions JSONMap `json:"permissions" gorm:"type:jsonb;not null"` // Permissions associated with the role
}

Jump to

Keyboard shortcuts

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