Documentation ¶
Index ¶
- func AssertNoUnmatchedRequests(t UnmatchedRequestsTestingT)
- func DeleteCreatedEntities(db *gorm.DB) func()
- type BufferLogger
- func (l *BufferLogger) Bytes() []byte
- func (l *BufferLogger) Critical(args ...interface{})
- func (l *BufferLogger) Criticalf(format string, args ...interface{})
- func (l *BufferLogger) Debug(args ...interface{})
- func (l *BufferLogger) Debugf(format string, args ...interface{})
- func (l *BufferLogger) Error(args ...interface{})
- func (l *BufferLogger) Errorf(format string, args ...interface{})
- func (l *BufferLogger) Fatal(args ...interface{})
- func (l *BufferLogger) Fatalf(format string, args ...interface{})
- func (l *BufferLogger) Info(args ...interface{})
- func (l *BufferLogger) Infof(format string, args ...interface{})
- func (l *BufferLogger) Notice(args ...interface{})
- func (l *BufferLogger) Noticef(format string, args ...interface{})
- func (l *BufferLogger) Panic(args ...interface{})
- func (l *BufferLogger) Panicf(format string, args ...interface{})
- func (l *BufferLogger) Read(p []byte) (n int, err error)
- func (l *BufferLogger) Reset()
- func (l *BufferLogger) String() string
- func (l *BufferLogger) Warning(args ...interface{})
- func (l *BufferLogger) Warningf(format string, args ...interface{})
- type BufferedLogger
- type ReadBuffer
- type TranslationsExtractor
- type UnmatchedRequestsTestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNoUnmatchedRequests ¶
func AssertNoUnmatchedRequests(t UnmatchedRequestsTestingT)
AssertNoUnmatchedRequests check that gock didn't receive any request that it was not able to match. It will print out an entire request data for every unmatched request.
func DeleteCreatedEntities ¶
DeleteCreatedEntities sets up GORM `onCreate` hook and return a function that can be deferred to remove all the entities created after the hook was set up. You can use it like this:
func TestSomething(t *testing.T){ db, _ := gorm.Open(...) cleaner := DeleteCreatedEntities(db) defer cleaner() }.
Types ¶
type BufferLogger ¶
type BufferLogger struct {
// contains filtered or unexported fields
}
BufferLogger is an implementation of the BufferedLogger.
func (*BufferLogger) Bytes ¶
func (l *BufferLogger) Bytes() []byte
Bytes is a shorthand for the underlying bytes.Buffer method. Returns byte slice with the buffer contents.
func (*BufferLogger) Critical ¶
func (l *BufferLogger) Critical(args ...interface{})
func (*BufferLogger) Criticalf ¶
func (l *BufferLogger) Criticalf(format string, args ...interface{})
func (*BufferLogger) Debug ¶
func (l *BufferLogger) Debug(args ...interface{})
func (*BufferLogger) Debugf ¶
func (l *BufferLogger) Debugf(format string, args ...interface{})
func (*BufferLogger) Error ¶
func (l *BufferLogger) Error(args ...interface{})
func (*BufferLogger) Errorf ¶
func (l *BufferLogger) Errorf(format string, args ...interface{})
func (*BufferLogger) Fatal ¶
func (l *BufferLogger) Fatal(args ...interface{})
func (*BufferLogger) Fatalf ¶
func (l *BufferLogger) Fatalf(format string, args ...interface{})
func (*BufferLogger) Info ¶
func (l *BufferLogger) Info(args ...interface{})
func (*BufferLogger) Infof ¶
func (l *BufferLogger) Infof(format string, args ...interface{})
func (*BufferLogger) Notice ¶
func (l *BufferLogger) Notice(args ...interface{})
func (*BufferLogger) Noticef ¶
func (l *BufferLogger) Noticef(format string, args ...interface{})
func (*BufferLogger) Panic ¶
func (l *BufferLogger) Panic(args ...interface{})
func (*BufferLogger) Panicf ¶
func (l *BufferLogger) Panicf(format string, args ...interface{})
func (*BufferLogger) Read ¶
func (l *BufferLogger) Read(p []byte) (n int, err error)
Read bytes from the logger buffer. io.Reader implementation.
func (*BufferLogger) Reset ¶
func (l *BufferLogger) Reset()
Reset is a shorthand for the underlying bytes.Buffer method. It will reset buffer contents.
func (*BufferLogger) String ¶
func (l *BufferLogger) String() string
String contents of the logger buffer. fmt.Stringer implementation.
func (*BufferLogger) Warning ¶
func (l *BufferLogger) Warning(args ...interface{})
func (*BufferLogger) Warningf ¶
func (l *BufferLogger) Warningf(format string, args ...interface{})
type BufferedLogger ¶
type BufferedLogger interface { ReadBuffer logger.Logger }
BufferedLogger is a logger that can return the data written to it.
func NewBufferedLogger ¶
func NewBufferedLogger() BufferedLogger
NewBufferedLogger returns new BufferedLogger instance.
type ReadBuffer ¶
ReadBuffer is implemented by the BufferLogger. Its methods give access to the buffer contents and ability to read buffer as an io.Reader or reset its contents.
type TranslationsExtractor ¶
type TranslationsExtractor struct { TranslationsFS fs.FS TranslationsPath string // contains filtered or unexported fields }
TranslationsExtractor is a tool to load raw translations data from files or from box. It is feasible to be used in tests in order to check translation files correctness. The easiest way to check correctness is to check keys in translations. TranslationsExtractor IS NOT supposed to check correctness of translations - it's just an extractor. Translations can be checked manually, or via external library like https://github.com/google/go-cmp
func NewTranslationsExtractor ¶
func NewTranslationsExtractor(fileNameTemplate string) *TranslationsExtractor
NewTranslationsExtractor constructor. Use "translate.{}.yml" as template if your translations are named like "translate.en.yml".
func (*TranslationsExtractor) GetMapKeys ¶
func (t *TranslationsExtractor) GetMapKeys(data map[string]interface{}) []string
GetMapKeys returns sorted map keys from map[string]interface{} - useful to check keys in several translation files.
func (*TranslationsExtractor) LoadLocale ¶
func (t *TranslationsExtractor) LoadLocale(locale string) (map[string]interface{}, error)
LoadLocale returns translation file data with provided locale.
func (*TranslationsExtractor) LoadLocaleKeys ¶
func (t *TranslationsExtractor) LoadLocaleKeys(locale string) ([]string, error)
LoadLocaleKeys returns only sorted keys from translation file.
type UnmatchedRequestsTestingT ¶
type UnmatchedRequestsTestingT interface { Log(...interface{}) Logf(string, ...interface{}) FailNow() }
UnmatchedRequestsTestingT contains all of *testing.T methods which are needed for AssertNoUnmatchedRequests.