test

package
v0.0.0-...-9914b64 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 13 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 test exposes test-only HTTP endpoints used by Cypress e2e against mk-go.

Every endpoint in this package is guarded by config.Config.TestMode. In production (TestMode=false) the routes are not registered at all, and any request to them returns the default Echo 404.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is the HTTP handler for test-only endpoints.

func NewEchoHandler

func NewEchoHandler() *Handler

NewEchoHandler constructs a Handler for the public `/api/test` endpoint.

**`/test` だけは `TestMode` で gate しない。** upstream は本番でも登録して おり、本家の backend e2e (`test/e2e/endpoints.ts`) がここを叩いて型変換と デフォルト値の挙動を確かめる。このパッケージの他の endpoint (`/reset-db` など) とは扱いが違うので、依存を持たない専用のコンストラクタを分けてある。

func NewHandler

func NewHandler(db *gorm.DB, redisClient *redis.Client, metaRepo repository.MetaRepository, testMode bool) *Handler

NewHandler constructs a new test Handler.

db and redis are both required when testMode is true. They are accepted regardless so that test code that spins up a zero-value Handler cannot accidentally pass a nil dependency without it being caught by the runtime.

func (*Handler) ResetDB

func (h *Handler) ResetDB(c *echo.Context) error

ResetDB wipes all user-visible tables and flushes Redis.

This mirrors Misskey 本家の `/api/reset-db` エンドポイントで、 Cypress の `resetState` カスタムコマンドが必須依存している。 TestMode=false の場合は 404 を返して存在しないように振る舞う。

func (*Handler) Test

func (h *Handler) Test(c *echo.Context) error

Test mirrors upstream `test.ts`, an endpoint whose only job is to echo back the parameter-validation behaviour of the API framework.

POST /api/test

Jump to

Keyboard shortcuts

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