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
30b3472f
Commit
30b3472f
authored
Jun 02, 2017
by
Andrzej Wasylkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new helper methods FailfWithOffset and ExpectNoErrorWithOffset.
parent
c13d8917
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
util.go
test/e2e/framework/util.go
+14
-2
No files found.
test/e2e/framework/util.go
View file @
30b3472f
...
@@ -286,9 +286,15 @@ func Logf(format string, args ...interface{}) {
...
@@ -286,9 +286,15 @@ func Logf(format string, args ...interface{}) {
}
}
func
Failf
(
format
string
,
args
...
interface
{})
{
func
Failf
(
format
string
,
args
...
interface
{})
{
FailfWithOffset
(
1
,
format
,
args
...
)
}
// FailfWithOffset calls "Fail" and logs the error at "offset" levels above its caller
// (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").
func
FailfWithOffset
(
offset
int
,
format
string
,
args
...
interface
{})
{
msg
:=
fmt
.
Sprintf
(
format
,
args
...
)
msg
:=
fmt
.
Sprintf
(
format
,
args
...
)
log
(
"INFO"
,
msg
)
log
(
"INFO"
,
msg
)
Fail
(
nowStamp
()
+
": "
+
msg
,
1
)
Fail
(
nowStamp
()
+
": "
+
msg
,
1
+
offset
)
}
}
func
Skipf
(
format
string
,
args
...
interface
{})
{
func
Skipf
(
format
string
,
args
...
interface
{})
{
...
@@ -1917,10 +1923,16 @@ func randomSuffix() string {
...
@@ -1917,10 +1923,16 @@ func randomSuffix() string {
}
}
func
ExpectNoError
(
err
error
,
explain
...
interface
{})
{
func
ExpectNoError
(
err
error
,
explain
...
interface
{})
{
ExpectNoErrorWithOffset
(
1
,
err
,
explain
...
)
}
// ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller
// (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
func
ExpectNoErrorWithOffset
(
offset
int
,
err
error
,
explain
...
interface
{})
{
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Unexpected error occurred: %v"
,
err
)
Logf
(
"Unexpected error occurred: %v"
,
err
)
}
}
ExpectWithOffset
(
1
,
err
)
.
NotTo
(
HaveOccurred
(),
explain
...
)
ExpectWithOffset
(
1
+
offset
,
err
)
.
NotTo
(
HaveOccurred
(),
explain
...
)
}
}
func
ExpectNoErrorWithRetries
(
fn
func
()
error
,
maxRetries
int
,
explain
...
interface
{})
{
func
ExpectNoErrorWithRetries
(
fn
func
()
error
,
maxRetries
int
,
explain
...
interface
{})
{
...
...
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