check: add unit tests to cover the new code, fix linter errors

This commit is contained in:
Ramkumar Chinchani
2020-01-30 23:59:36 -08:00
parent f9a1a0fe48
commit 58040f4562
5 changed files with 157 additions and 45 deletions
+5 -2
View File
@@ -54,10 +54,11 @@ func (e ErrorCode) String() string {
DENIED: "DENIED",
UNSUPPORTED: "UNSUPPORTED",
}
return m[e]
}
func NewError(code ErrorCode, detail ...interface{}) Error {
func NewError(code ErrorCode, detail ...interface{}) Error { //nolint (interfacer)
var errMap = map[ErrorCode]Error{
BLOB_UNKNOWN: {
Message: "blob unknown to registry",
@@ -166,9 +167,11 @@ func NewError(code ErrorCode, detail ...interface{}) Error {
func NewErrorList(errors ...Error) ErrorList {
el := make([]*Error, 0)
er := Error{}
for _, e := range errors {
el = append(el, &e)
er = e
el = append(el, &er)
}
return ErrorList{el}