tests

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tests is the base every test in this project builds on.

It is tests/TestCase.php, in the shape Go allows: a package the suites import rather than a class they extend. What belongs here is what more than one suite needs -- booting the application, opening a database, reading a file from the project root -- and nothing else. A helper used by one test belongs beside it.

The two suites are the Laravel ones and they mean the same thing:

tests/Feature/  boots the application and makes a request
tests/Unit/     checks one thing without booting anything

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func App

func App(t *testing.T) (*arandutest.Client, *data.DB)

App boots the whole application on a throwaway SQLite database, migrated, and returns a browser for it.

It is Laravel's RefreshDatabase and $this->get() in one call, and it is the difference between a feature test worth writing and one nobody writes: every alternative starts with twelve lines of environment, connection and migration that have nothing to do with what is being proved.

SQLite in a temporary directory, so the tests need nothing installed and two of them cannot see each other's rows. The file goes with t.TempDir.

func File

func File(t *testing.T, name string) string

File reads one file from the project root.

func Kernel

func Kernel(t *testing.T, env config.Env) *kernel.Kernel

Kernel needs no database. database/sql connects lazily, so the wiring, the pipeline and every route can be exercised without a server running -- which is what makes this a useful smoke test to keep in a project skeleton. Kernel boots the application for a test.

Exported because both suites use it, which is the whole reason this package exists.

func Root

func Root(t *testing.T) string

Root is the project root, from inside a suite directory.

The tests that read a file -- the Dockerfile, the workflow, arandu.toml -- run two directories down from it now, and a relative path written from the old location silently reads nothing: os.ReadFile returns an error the test reports as "the file does not say X", which is true and misleading.

Types

This section is empty.

Jump to

Keyboard shortcuts

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