lib

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tst contains no runtime code, only universal helper for tests

Package lib contains helper functions for trice tool

Package tst contains no runtime code, only universal helper for tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(tb testing.TB, condition bool, msg string, v ...interface{})

Assert fails the test if the condition is false.

func Assign

func Assign(fn string) string

func CleanFile added in v0.8.3

func CleanFile(fileName string)

CleanFile accepts a string representing a path and converts \r\n into \n (taken from https://github.com/cgati/dos2unix/blob/master/main.go)

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func EqualFile added in v0.8.3

func EqualFile(t *testing.T, fn, s string)

EqualFile fails test if s is NOT equal to contence of fn Different lineendings are ignored

func EqualFileContent added in v0.8.3

func EqualFileContent(fn0, fn1 string) bool

EqualFileContent returns true if contece is equal

func EqualFiles added in v0.8.3

func EqualFiles(t *testing.T, fn0, fn1 string)

EqualFiles fails test if contence is NOT equal

func EqualFiles2 added in v0.8.3

func EqualFiles2(t *testing.T, fn0, fn1 string)

EqualFiles2 fails test if contence is NOT equal Different lineendings are ignored

func Equals

func Equals(tb testing.TB, exp, act interface{})

Equals fails the test if exp is not equal to act.

func Ok

func Ok(tb testing.TB, err error)

Ok fails the test if an err is not nil.

func ReadLines

func ReadLines(file string) ([]string, error)

WriteLines writes string slice containing lines to file

func Timestamp added in v0.8.3

func Timestamp() string

Timestamp returns local time as string according var TimeStampFormat https://www.alexedwards.net/blog/an-overview-of-go-tooling#managing-dependencies

func UniqLines

func UniqLines(t *testing.T, inFile, outFile string) int

UniqLines reads inFile, removes duplicate lines and writes to outFile inFile and outFile can be the same it returns count of remaining lines plus 1 (io.EOF ?)

func WriteLines

func WriteLines(file string, lines []string) error

WriteLines writes string slice containing lines to file

Types

type ArrayFlag

type ArrayFlag []string

ArrayFlag is a slice type for multi flag

var (
	Srcs ArrayFlag // gets multiple files or directories

	// TimeStampFormat is the PC timestamp format
	TimeStampFormat = "off"
)

func (*ArrayFlag) Set

func (i *ArrayFlag) Set(value string) error

func (*ArrayFlag) String

func (i *ArrayFlag) String() string

Jump to

Keyboard shortcuts

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