contexttest

package
v3.1.60 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT, MIT Imports: 25 Imported by: 0 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

Overview

Package contexttest provides utilities for testing Web/API contexts with models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadGitRepo

func LoadGitRepo(t *testing.T, ctx gocontext.Context)

LoadGitRepo load a git repo into a test context. Requires that ctx.Repo has already been populated.

func LoadRepo

func LoadRepo(t *testing.T, ctx gocontext.Context, repoID int64)

LoadRepo load a repo into a test context.

func LoadRepoCommit

func LoadRepoCommit(t *testing.T, ctx gocontext.Context)

LoadRepoCommit loads a repo's commit into a test context.

func LoadUser

func LoadUser(t *testing.T, ctx gocontext.Context, userID int64)

LoadUser load a user into a test context

func MockAPIContext

func MockAPIContext(t *testing.T, reqPath string) (*context.APIContext, *httptest.ResponseRecorder)

MockAPIContext mock context for unit tests

func MockContext

func MockContext(t *testing.T, reqPath string, opts ...MockContextOption) (*context.Context, *httptest.ResponseRecorder)

MockContext mock context for unit tests

func MockPrivateContext

func MockPrivateContext(t *testing.T, reqPath string) (*context.PrivateContext, *httptest.ResponseRecorder)

Types

type MockContextOption

type MockContextOption struct {
	Render       context.Render
	SessionStore session.Store
}

type MockRender

type MockRender struct{}

func (*MockRender) HTML

func (tr *MockRender) HTML(w io.Writer, status int, _ templates.TplName, _ any, _ gocontext.Context) error

func (*MockRender) TemplateLookup

func (tr *MockRender) TemplateLookup(tmpl string, _ gocontext.Context) (templates.TemplateExecutor, error)

Source Files

  • context_tests.go

Jump to

Keyboard shortcuts

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