testlib

package
v0.0.0-...-9392aba Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package testlib provides utilities for testing

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoesPanic

func DoesPanic(f func()) (panicked bool, recovered interface{})

DoesPanic runs f and checks if it panicked or not. When f does panic, returns the recovered value.

Example (Normal)

DoesPanic behavior for a function that does not panic

didPanic, _ := DoesPanic(func() {
	/* do nothing */
})
fmt.Printf("didPanic = %t\n", didPanic)
Output:

didPanic = false
Example (Panic)

DoesPanic behavior for a panicking function

didPanic, recovered := DoesPanic(func() {
	panic("some error message")
})
fmt.Printf("didPanic = %t\n", didPanic)
fmt.Printf("recover() = %v\n", recovered)
Output:

didPanic = true
recover() = some error message

func TempDirAbs

func TempDirAbs(t *testing.T) string

TempDirAbs is like the TempDir method of t, but resolves all symlinks in the returned path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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