Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
go-orusapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orus-io
go-orusapi
Commits
2f75d76afdfa
Commit
2f75d76afdfa
authored
4 years ago
by
Christophe de Vienne
Browse files
Options
Downloads
Patches
Plain Diff
Add the 'testutils' package
parent
d6032c71d396
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#6241
passed
4 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testutils/logger.go
+40
-0
40 additions, 0 deletions
testutils/logger.go
with
40 additions
and
0 deletions
testutils/logger.go
0 → 100644
+
40
−
0
View file @
2f75d76a
package
testutils
import
(
"os"
"testing"
"github.com/rs/zerolog"
)
//NewTestLogger creates a TestLogger
func
NewTestLogger
(
tb
testing
.
TB
)
*
TestLogger
{
return
&
TestLogger
{
tb
}
}
// TestLogger logs to a t.Log function
type
TestLogger
struct
{
tb
testing
.
TB
}
// Logger returns a zerolog Logger
func
(
tl
*
TestLogger
)
Logger
()
zerolog
.
Logger
{
level
:=
zerolog
.
DebugLevel
if
os
.
Getenv
(
"TEST_TRACE"
)
!=
""
{
level
=
zerolog
.
TraceLevel
}
return
zerolog
.
New
(
zerolog
.
ConsoleWriter
{
Out
:
tl
})
.
With
()
.
Timestamp
()
.
Logger
()
.
Level
(
level
)
}
// Write writes the given string to t.Logf
func
(
tl
*
TestLogger
)
Write
(
m
[]
byte
)
(
int
,
error
)
{
tl
.
tb
.
Logf
(
string
(
m
))
return
len
(
m
),
nil
}
// GetLogger returns a test Logger
func
GetLogger
(
tb
testing
.
TB
)
zerolog
.
Logger
{
return
NewTestLogger
(
tb
)
.
Logger
()
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment