testutils

package
v0.0.0-...-4704a60 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(cmd *cobra.Command, args ...string) string

Execute a cobra command with custom args for testing using *bytes.Buffer under the hood.

Since the root cmd is used for testing, any subcommands the root command has will have to be included in the args

func First8

func First8(s int64) string

To be used in get_test.go, see the "NOTE" comment left in that file.

func GoModTidy

func GoModTidy(t *testing.T)

Use this for the "get" command tests.

When running these tests locally it can affect our go.mod file, which would need to get cleaned up after every test

This is not the most clever way of handling this issue, but it's a whole FUCK of alot easier then... idk say spinning up a docker container with a dedicated go project directory just for these tests. And it suprisingly works a lot better than I thought it would

func InMemDb

func InMemDb(t *testing.T) (*database.Queries, context.Context)

Spin up an in memory database (since we're using sqlite3) for quick testing

This function already includes a cleanup function where when the test completes, the database is closed

func Mock1outof3pkgs

func Mock1outof3pkgs(t *testing.T) string

Mock the $GOPATH/pkg/mod/github.com dir using the test's TempDir

Only 1 out of 3 dirs should be "valid"

func Mock3outof3pkgs

func Mock3outof3pkgs(t *testing.T) string

Mock the $GOPATH/pkg/mod/github.com dir using the test's TempDir

Only 3 out of 3 dirs should be "valid"

Types

This section is empty.

Jump to

Keyboard shortcuts

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