Documentation
¶
Index ¶
- Constants
- Variables
- func CopyPNG(tb testing.TB, dest string)
- func CopyTXT(tb testing.TB, dest string)
- func CountTest() int
- func DB(tb testing.TB) *sql.DB
- func DOSBIN(tb testing.TB, s string) [4000]byte
- func EmbedFS(tb testing.TB) fs.FS
- func Middleware(tb testing.TB, e *echo.Echo, target string) *echo.Context
- func MiddlewareStatus(tb testing.TB, e *echo.Echo, target string, status int) *echo.Context
- func MkDOSBIN(tb testing.TB, name, s string) (string, error)
- func NewContext(tb testing.TB, target string) *echo.Context
- func NewFile(tb testing.TB, target, fieldname, filename string) *echo.Context
- func NewFileInputs(tb testing.TB, target, fieldname, filename string, formInputs Input) *echo.Context
- func NewInput(tb testing.TB, target, key, value string) *echo.Context
- func NewInputs(tb testing.TB, target string, formInputs Input) *echo.Context
- func NewInputsPath(tb testing.TB, target string, formInputs Input, pathValues echo.PathValues) *echo.Context
- func NewModel(tb testing.TB) *models.File
- func NewPath(tb testing.TB, target string, pathValues echo.PathValues) *echo.Context
- func OpenFS(tb testing.TB) fs.FS
- func OpenRoot(tb testing.TB) *os.Root
- func Project() string
- func ProjectFS(tb testing.TB) fs.FS
- func Testdata() string
- func Tx(tb testing.TB) *sql.Tx
- type ANSITest
- type Input
- type Logger
- type TestData
- type Testfile
Constants ¶
const ( YT = "3V8rpJDpbKg" // YTID is an example YouTube video ID UID = "123e4567-e89b-12d3-a456-426614174000" // UUID is a generic Universal Unique ID UID4 = "bb2310e1-93aa-475e-8b88-59eb1fb984a4" // UID4 is a UUID version 4 SCREENPNG = 328_468 // SCREENPNG is the byte file size of testdata/SCREEN.PNG // RTF is an example of Rich-Text-Format encoded text. RTF = `{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard This is some {\b bold} text.\par }` )
Variables ¶
var Content1 = [...]string{
"file1.nfo",
"file1.txt",
"file1.unp",
"file1.doc",
}
var Content2 = [...]string{
"file.diz",
"file.asc",
"file.1st",
"group2.dox",
}
var Content3 = [...]string{
"file3.nfo",
"file.txt",
"file30.unp",
"file3x.doc",
"filex3.diz",
"file3.asc",
"file3.1st",
"file3.dox",
}
Functions ¶
func CountTest ¶
func CountTest() int
CountTest returns the number of TestData entries that have a filename prefix of "TEST." (test plus a dot).
func DB ¶
DB returns a shared Postgres database connection for use with tests. If no connection can be made, the test is skipped.
func DOSBIN ¶
DOSBIN converts the string into a single page, MS-DOS BIN binary text. If s is left empty, "hello world" will be used. Long strings will be cropped to fit the 80 column * 25 row per page limit.
func Middleware ¶
Middleware returns an *echo.Context for a GET request to target. If no target is provided, it is set to root "/".
The echo.Echo can be provided using echo.New.
func MiddlewareStatus ¶
MiddlewareStatus returns an *echo.Context for a GET request to target with the response status header already written.
The echo.Echo can be provided using echo.New.
func MkDOSBIN ¶
MkDOSBIN converts the string into a single line, MS-DOS BIN file saved to the named file and placed in a temporary test directory. The file location is returned.
See DOSBIN.
func NewContext ¶
NewContext creates a new instance of Echo and returns an *echo.Context for a GET request to target. If no target is provided, it is set to root "/". Query params can also be provided using target, for example:
target="/myurl?id=1&name=hello"
func NewFile ¶
NewFile creates a new Echo context with a multipart POST containing an embedded textfile upload.
- fieldname is the named input of the form containing the upload.
- filename is the original filename of the file upload.
- The upload contains the following string, "Hello world!".
func NewFileInputs ¶
func NewFileInputs(tb testing.TB, target, fieldname, filename string, formInputs Input, ) *echo.Context
NewFileInputs functions the same as NewFile but also allows for additional form inputs using Input, for example:
inputs := testutil.Input{
"id": "1",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
}
func NewInput ¶
NewInput creates a new instance of Echo and returns an *echo.Context for a POST request with a single application/x-www-form-urlencoded form key and value. If no target is provided, it is set to root "/".
func NewInputs ¶
NewInputs creates a new Echo context for a multipart/form-data POST request populated with the form fields in formInputs.
func NewInputsPath ¶
func NewModel ¶
NewModel returns a new models.File entry with the following boilerplate:
- ID: 1
- UUID: bb2310e1-93aa-475e-8b88-59eb1fb984a4
- Filename: filename.txt
- Filesize: 9876
func NewPath ¶
NewPath creates a new Echo context for a GET request with a collection of echo.PathValues, providing path parameters using Name and Value pairs.
func OpenFS ¶
OpenFS opens the root directory of this Go project as an fs.FS and closes it on cleanup.
func Project ¶
func Project() string
Project returns the absolute path to the root directory of this project repository.
func ProjectFS ¶
ProjectFS opens the root directory of this Go project as an fs.FS and closes it on cleanup.
func Testdata ¶
func Testdata() string
Testdata returns the absolute representation to the "testdata/" subdirectory found in this testutil package.
Types ¶
type Logger ¶
type TestData ¶
type Testfile ¶
type Testfile string // Testfile is the key used to reference TestData.
func FileData ¶
FileData returns the filename of the key testdata.
For example:
FileData("logotxt") = "LOGO.TXT"