Documentation
¶
Overview ¶
Package testutil provides shared testing utilities for go_by_examples.
Index ¶
- func AssertOutput(got, want string) bool
- func CaptureOutput(f func()) string
- func ContainsOutput(output, substring string) bool
- func CreateTempFile(dir, prefix string, content []byte) (string, func(), error)
- func DirExists(path string) bool
- func FileExists(path string) bool
- func ListFiles(dir string) ([]string, error)
- func ReadFile(path string) ([]byte, error)
- func TempDir(prefix string) (string, func(), error)
- func WriteFile(path string, data []byte) error
- type HTTPTestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertOutput ¶
AssertOutput is a helper function to verify program output in tests.
func CaptureOutput ¶
func CaptureOutput(f func()) string
CaptureOutput runs the given function and captures its stdout output. It returns the captured output as a string.
func ContainsOutput ¶
ContainsOutput is a helper function to check if output contains expected string.
func CreateTempFile ¶
CreateTempFile creates a temporary file with the given content. Returns the file path and a cleanup function.
func FileExists ¶
FileExists checks if a file exists at the given path
Types ¶
type HTTPTestServer ¶
HTTPTestServer represents a test HTTP server
func NewHTTPTestServer ¶
func NewHTTPTestServer(handler http.HandlerFunc) *HTTPTestServer
NewHTTPTestServer creates a new test HTTP server with the given handler
Click to show internal directories.
Click to hide internal directories.