fc

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 19

Documentation

Overview

Utility functions working with FreeCONF library

Index

Constants

This section is empty.

Variables

View Source
var BadRequestError = errors.New("bad request")

BadRequestError is when end user is attempting to perform an operation that is invalid. When used with RESTCONF context, will result in 400 error.

View Source
var ConflictError = errors.New("conflict")

ConflictError is when multiple attempts to do something cannot be completed When used with RESTCONF context, will result in 409 error.

View Source
var Debug *log.Logger

Debug is discarded unless -debug flag is passed on CLI.

Err is for errors only. An error is somethhing that deserves immediate attention

View Source
var Info *log.Logger

Info is Warnings, or general information.

View Source
var NotFoundError = errors.New("not found")

NotFoundError is when a resource is not found. When used with RESTCONF context will result in 404 error

View Source
var NotImplementedError = errors.New("not implemented")

NotImplementedError is when something wasn't implemented and may be an optional part of the spec or a particular feature wasn't impemented When used with RESTCONF context, will result in 501 error.

View Source
var UnauthorizedError = errors.New("not authorized")

UnauthorizedError when someone is attempting to do something they do not have access to

Functions

func AssertEqual

func AssertEqual(t Tester, a interface{}, b interface{}, msgs ...string) bool

AssertEqual emits testing error if a and b are not equal. Returns true if equal

func DebugLog

func DebugLog(e bool)

DebugLog turns on debug level logging

func DebugLogEnabled

func DebugLogEnabled() bool

DebugLogEnabled returns whether debug level logging is on or not

func Diff

func Diff(t Tester, a []byte, b string) bool

Diff will compare byte array to file and emit formatted difference useful in "Golden File Testing", return true if no differences

func DiffBytes

func DiffBytes(t Tester, a []byte, b []byte) bool

DiffBytes will compare two byte arrays and emit formatted difference useful in "Golden File Testing", return true if no differences

func DiffFiles

func DiffFiles(t Tester, a string, b string) bool

DiffFiles will compare two files and emit formatted difference useful in "Golden File Testing", return true if no differences

func Gold

func Gold(t Tester, update bool, actual []byte, gfile string) bool

Gold compares bytes to a the contents of a file on disk UNLESS update flag is passed, then it replaces contents of file on disk. This testing strategy if known as "gold files" and can be found in many projects including the Go SDK

func GoldFile

func GoldFile(t Tester, update bool, actualFile string, gfile string) bool

Gold compares one file to a the contents of a file on disk UNLESS update flag is passed, then it replaces contents of file on disk. This testing strategy if known as "gold files" and can be found in many projects including the Go SDK

func HttpStatusCode

func HttpStatusCode(err error) int

HttpableError will see if error be converted to one of non-500 errors

func MapValue

func MapValue(parent interface{}, key ...interface{}) interface{}

MapValue used in unit tests, not intended for use outsite this golang module so this function may be subject to change w/o warning

func RequireEqual

func RequireEqual(t Tester, a interface{}, b interface{}, msgs ...string) bool

RequireEqual is like AssertEqual except it aborts rest of test

Types

type Tester

type Tester interface {
	Helper()
	Error(args ...interface{})
	Fatal(args ...interface{})
}

Tester is internal. Here just to decouple test utilities from testing.T package.

Jump to

Keyboard shortcuts

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