difftest

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package difftest implement test based on serialized string output

User provides a function that gets a input string. It returns a output string based on the input somehow and a output path to file with content to compare it to or to write to if in write mode. If there is a difference test will fail with a diff.

Test inputs are read from files matching Pattern from Path.

Note that output path can be the same as input which useful if the function implements some kind of transcript that includes both input and output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(t tf, expected string, actual string)

func ErrorEx

func ErrorEx(t tf, color bool, expected string, actual string)

func Fatal

func Fatal(t tf, expected string, actual string)

func FatalEx

func FatalEx(t tf, color bool, expected string, actual string)

func Test

func Test(t *testing.T, pattern string, fn Fn)

func TestWithOptions

func TestWithOptions(t *testing.T, opts Options)

Types

type Fn

type Fn func(t *testing.T, path string, input string) (string, string, error)

type Options

type Options struct {
	Path        string
	Pattern     string
	ColorDiff   bool
	WriteOutput bool
	Fn          Fn
}

Jump to

Keyboard shortcuts

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