Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
bca3780b
Commit
bca3780b
authored
Nov 03, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused matcher
parent
48b49a5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
25 deletions
+1
-25
errors.go
pkg/util/validation/errors.go
+1
-13
errors_test.go
pkg/util/validation/errors_test.go
+0
-12
No files found.
pkg/util/validation/errors.go
View file @
bca3780b
...
@@ -172,7 +172,7 @@ func (list ErrorList) PrefixIndex(index int) ErrorList {
...
@@ -172,7 +172,7 @@ func (list ErrorList) PrefixIndex(index int) ErrorList {
return
list
.
Prefix
(
fmt
.
Sprintf
(
"[%d]"
,
index
))
return
list
.
Prefix
(
fmt
.
Sprintf
(
"[%d]"
,
index
))
}
}
// New
ValidationErrorFieldPrefix
Matcher returns an errors.Matcher that returns true
// New
ErrorType
Matcher returns an errors.Matcher that returns true
// if the provided error is a Error and has the provided ErrorType.
// if the provided error is a Error and has the provided ErrorType.
func
NewErrorTypeMatcher
(
t
ErrorType
)
utilerrors
.
Matcher
{
func
NewErrorTypeMatcher
(
t
ErrorType
)
utilerrors
.
Matcher
{
return
func
(
err
error
)
bool
{
return
func
(
err
error
)
bool
{
...
@@ -183,18 +183,6 @@ func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher {
...
@@ -183,18 +183,6 @@ func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher {
}
}
}
}
// NewValidationErrorFieldPrefixMatcher returns an errors.Matcher that returns true
// if the provided error is a Error and has a field with the provided
// prefix.
func
NewValidationErrorFieldPrefixMatcher
(
prefix
string
)
utilerrors
.
Matcher
{
return
func
(
err
error
)
bool
{
if
e
,
ok
:=
err
.
(
*
Error
);
ok
{
return
strings
.
HasPrefix
(
e
.
Field
,
prefix
)
}
return
false
}
}
// Filter removes items from the ErrorList that match the provided fns.
// Filter removes items from the ErrorList that match the provided fns.
func
(
list
ErrorList
)
Filter
(
fns
...
utilerrors
.
Matcher
)
ErrorList
{
func
(
list
ErrorList
)
Filter
(
fns
...
utilerrors
.
Matcher
)
ErrorList
{
err
:=
utilerrors
.
FilterOut
(
utilerrors
.
NewAggregate
(
list
),
fns
...
)
err
:=
utilerrors
.
FilterOut
(
utilerrors
.
NewAggregate
(
list
),
fns
...
)
...
...
pkg/util/validation/errors_test.go
View file @
bca3780b
...
@@ -105,18 +105,6 @@ func TestErrListFilter(t *testing.T) {
...
@@ -105,18 +105,6 @@ func TestErrListFilter(t *testing.T) {
if
len
(
list
.
Filter
(
NewErrorTypeMatcher
(
ErrorTypeInvalid
)))
!=
1
{
if
len
(
list
.
Filter
(
NewErrorTypeMatcher
(
ErrorTypeInvalid
)))
!=
1
{
t
.
Errorf
(
"should filter"
)
t
.
Errorf
(
"should filter"
)
}
}
if
len
(
list
.
Filter
(
NewValidationErrorFieldPrefixMatcher
(
"test"
)))
!=
1
{
t
.
Errorf
(
"should filter"
)
}
if
len
(
list
.
Filter
(
NewValidationErrorFieldPrefixMatcher
(
"test."
)))
!=
2
{
t
.
Errorf
(
"should filter"
)
}
if
len
(
list
.
Filter
(
NewValidationErrorFieldPrefixMatcher
(
""
)))
!=
0
{
t
.
Errorf
(
"should filter"
)
}
if
len
(
list
.
Filter
(
NewValidationErrorFieldPrefixMatcher
(
"field."
),
NewErrorTypeMatcher
(
ErrorTypeDuplicate
)))
!=
1
{
t
.
Errorf
(
"should filter"
)
}
}
}
func
TestErrListPrefix
(
t
*
testing
.
T
)
{
func
TestErrListPrefix
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment