Documentation
¶
Index ¶
- Constants
- Variables
- func CopyPNG(tb testing.TB, dest string)
- func CopyTXT(tb testing.TB, dest string)
- func Count() int
- func CountTest() int
- func DB(tb testing.TB) *sql.DB
- func DBConns(tb testing.TB)
- 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(t *testing.T, target, fieldname, filename string) *echo.Context
- func NewFileInputs(t *testing.T, target, fieldname, filename string, formInputs Input) *echo.Context
- func NewInput(tb testing.TB, target, key, value string) *echo.Context
- func NewInputs(t *testing.T, target string, formInputs Input) *echo.Context
- func NewInputsPath(t *testing.T, target string, formInputs Input, pathValues echo.PathValues) *echo.Context
- func NewModel(tb testing.TB) *models.File
- func NewPath(t *testing.T, 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 response using the target url. 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 response using http request using the target url and http status.
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 a response using the target url. 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 instance with 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(t *testing.T, 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:
Input["id"] = 1 Input["uuid"] = 123e4567-e89b-12d3-a456-426614174000
func NewInput ¶
NewInput creates a new instance of Echo and returns a response using the target url. It sets the key and value that are mapped as both query parameters and form values. If no target is provided, it is set to root "/".
func NewInputs ¶
NewInputs creates a new Echo instance and returns a response using the target url. It accepts an Input map using keys and values that are treated as both query parameters and form values.
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 instance with a collection of echo.PathValues, that allow the provision path parameters using Name and Value pairs.
func Project ¶
func Project() string
Project returns the absolute representation to the root directory for this project repository.
func Testdata ¶
func Testdata() string
Testdata returns the absolute representation to the "testdata/" subdirectory found in this testutil package.