gctest

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: EUPL-1.2, ISC, MIT, + 1 more Imports: 15 Imported by: 0

Documentation

Overview

Package gctest contains testing helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context

func Context(db zdb.DB) context.Context

Context creates a new test context.

func DB

func DB(t testing.TB) context.Context

DB starts a new database test.

func DBFile

func DBFile(t testing.TB) context.Context

DBFile is like DB(), but guarantees that the database will be written to disk, whereas DB() may store it in memory.

You can get the connection string from the GCTEST_CONNECT environment variable.

func Reset

func Reset()

Reset global state.

func Site

func Site(ctx context.Context, t *testing.T, site *goatcounter.Site, user *goatcounter.User) context.Context

Site creates a new user/site pair.

You can set values for the site by passing the sute or user parameters, but they may be nul to just set them to some sensible defaults.

func StoreHits

func StoreHits(ctx context.Context, t *testing.T, wantFail bool, hits ...goatcounter.Hit) []goatcounter.Hit

StoreHits is a convenient helper to store hits in the DB via Memstore and cron.UpdateStats().

Types

This section is empty.

Jump to

Keyboard shortcuts

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