thelper

package
v0.0.0-...-7112f6d Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package thelper contains testing helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFileToFs

func AddFileToFs(t *testing.T, filename string, content []byte, baseFs afero.Fs)

AddFileToFs creates a file with the given filename filled with the content on the baseFs

func AddFileToFsByName

func AddFileToFsByName(t *testing.T, filename, subset string, baseFs afero.Fs)

AddFileToFsByName looks for the filename given over the related testdata dir and creates the file on the baseFs Notice the new file will be located in /{filename} path

func CmpIfErr

func CmpIfErr(t *testing.T, err error, old, actual, new interface{}, msg string)

CmpIfErr is the macro which'll take an error and the expected cases (old actual and new) In case of being errored, it'll cmp actual with old (to check if there are undesired changes) Else, it'll cmp actual with new (to check if the changes are correct)

func CmpWithGoldenFile

func CmpWithGoldenFile(t *testing.T, got []byte, goldenFilename, msg string)

CmpWithGoldenFile performs cmp over the goldenFile and the got bytes given Note: avoid testdata/%s when giving the filename

func IOExist

func IOExist(t *testing.T, Fs afero.Fs, sth string, existFunc func(afero.Fs, string) (bool, error)) bool

IOExist wraps afero utility func for checking existances (.DirExists, .Exists) over the given args and handles the error given of given T

func IOReadFile

func IOReadFile(t *testing.T, Fs afero.Fs, sth string) []byte

IOReadFile wraps afero.ReadFile over the given args and handles the error given of given T

func MockDB

func MockDB(t *testing.T) (db *sqlx.DB, mock sqlmock.Sqlmock)

MockDB wraps sqlmock.New with sqlx to return *sqlx.DB with sqlmock.Mock

func ReadJsonnet

func ReadJsonnet(t *testing.T, name string) []byte

ReadJsonnet reads the jsonnet given from the specified file It'll add the boilerplate of testdata/%s.jsonnet Is the broda of assist.ReadJsonnet, but in a t.Helper() version

Types

This section is empty.

Jump to

Keyboard shortcuts

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