Help us shape the future of Go! Take the 2026 Go Developer Survey

test

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllowSkipExternalService = sync.OnceValue(func() bool {
	isLocalTesting := os.Getenv("CI") == ""
	ciSkipExternal, _ := strconv.ParseBool(os.Getenv("GITEA_TEST_CI_SKIP_EXTERNAL"))
	return isLocalTesting || ciSkipExternal
})

Functions

func CompressGzip

func CompressGzip(content string) *bytes.Buffer

func ExternalServiceHTTP added in v1.3.0

func ExternalServiceHTTP(t TestingT, envVarName, def string) string

func IsNormalPageCompleted

func IsNormalPageCompleted(s string) bool

func MockVariableValue

func MockVariableValue[T any](p *T, v ...T) (reset func())

func NormalizeHTMLAttributes added in v1.3.0

func NormalizeHTMLAttributes(t TestingT, s string) string

func NormalizeHTMLSpaces added in v1.3.0

func NormalizeHTMLSpaces(s string) string

func ParseJSONError

func ParseJSONError(buf []byte) (ret struct {
	ErrorMessage string `json:"errorMessage"`
	RenderFormat string `json:"renderFormat"`
},
)

func ParseJSONRedirect

func ParseJSONRedirect(buf []byte) (ret struct {
	Redirect *string `json:"redirect"`
},
)

func ReadAllTarGzContent

func ReadAllTarGzContent(r io.Reader) (map[string]string, error)

func RedirectURL

func RedirectURL(resp http.ResponseWriter) string

RedirectURL returns the redirect URL of a http response. It also works for JSONRedirect: `{"redirect": "..."}` FIXME: it should separate the logic of checking from header and JSON body

func SecureSSHPrivateKey added in v1.3.0

func SecureSSHPrivateKey(path string) error

SecureSSHPrivateKey restricts a fixture key to its current owner for OpenSSH.

func WriteTarArchive

func WriteTarArchive(files map[string]string) *bytes.Buffer

func WriteTarCompression

func WriteTarCompression[F func(io.Writer) io.WriteCloser | func(io.Writer) (io.WriteCloser, error)](compression F, files map[string]string) *bytes.Buffer

func WriteZipArchive

func WriteZipArchive(files map[string]string) *bytes.Buffer

Types

type LogChecker

type LogChecker struct {
	*log.EventWriterBaseImpl
	// contains filtered or unexported fields
}

func NewLogChecker

func NewLogChecker(namePrefix string) (logChecker *LogChecker, cancel func())

func (*LogChecker) Check

func (lc *LogChecker) Check(d time.Duration) (filtered []bool, stopped bool)

Check returns the filtered slice and whether the stop mark is reached.

func (*LogChecker) Filter

func (lc *LogChecker) Filter(msgs ...string) *LogChecker

Filter will make the `Check` function to check if these logs are outputted.

func (*LogChecker) Run

func (lc *LogChecker) Run(ctx context.Context)

func (*LogChecker) StopMark

func (lc *LogChecker) StopMark(msg string) *LogChecker

type TestingT added in v1.3.0

type TestingT interface {
	Helper()
	Skipf(format string, args ...any)
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
}

Jump to

Keyboard shortcuts

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