Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
3b129607
Commit
3b129607
authored
Oct 14, 2014
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethlog: Reset before each test
parent
dac128a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
loggers_test.go
ethlog/loggers_test.go
+12
-4
No files found.
ethlog/loggers_test.go
View file @
3b129607
...
@@ -29,6 +29,8 @@ func (t *TestLogSystem) GetLogLevel() LogLevel {
...
@@ -29,6 +29,8 @@ func (t *TestLogSystem) GetLogLevel() LogLevel {
}
}
func
TestLoggerFlush
(
t
*
testing
.
T
)
{
func
TestLoggerFlush
(
t
*
testing
.
T
)
{
Reset
()
logger
:=
NewLogger
(
"TEST"
)
logger
:=
NewLogger
(
"TEST"
)
testLogSystem
:=
&
TestLogSystem
{
level
:
WarnLevel
}
testLogSystem
:=
&
TestLogSystem
{
level
:
WarnLevel
}
AddLogSystem
(
testLogSystem
)
AddLogSystem
(
testLogSystem
)
...
@@ -36,7 +38,6 @@ func TestLoggerFlush(t *testing.T) {
...
@@ -36,7 +38,6 @@ func TestLoggerFlush(t *testing.T) {
logger
.
Errorf
(
"."
)
logger
.
Errorf
(
"."
)
}
}
Flush
()
Flush
()
Reset
()
output
:=
testLogSystem
.
Output
output
:=
testLogSystem
.
Output
if
output
!=
"[TEST] .[TEST] .[TEST] .[TEST] .[TEST] ."
{
if
output
!=
"[TEST] .[TEST] .[TEST] .[TEST] .[TEST] ."
{
t
.
Error
(
"Expected complete logger output '[TEST] .[TEST] .[TEST] .[TEST] .[TEST] .', got "
,
output
)
t
.
Error
(
"Expected complete logger output '[TEST] .[TEST] .[TEST] .[TEST] .[TEST] .', got "
,
output
)
...
@@ -44,6 +45,8 @@ func TestLoggerFlush(t *testing.T) {
...
@@ -44,6 +45,8 @@ func TestLoggerFlush(t *testing.T) {
}
}
func
TestLoggerPrintln
(
t
*
testing
.
T
)
{
func
TestLoggerPrintln
(
t
*
testing
.
T
)
{
Reset
()
logger
:=
NewLogger
(
"TEST"
)
logger
:=
NewLogger
(
"TEST"
)
testLogSystem
:=
&
TestLogSystem
{
level
:
WarnLevel
}
testLogSystem
:=
&
TestLogSystem
{
level
:
WarnLevel
}
AddLogSystem
(
testLogSystem
)
AddLogSystem
(
testLogSystem
)
...
@@ -52,7 +55,6 @@ func TestLoggerPrintln(t *testing.T) {
...
@@ -52,7 +55,6 @@ func TestLoggerPrintln(t *testing.T) {
logger
.
Infoln
(
"info"
)
logger
.
Infoln
(
"info"
)
logger
.
Debugln
(
"debug"
)
logger
.
Debugln
(
"debug"
)
Flush
()
Flush
()
Reset
()
output
:=
testLogSystem
.
Output
output
:=
testLogSystem
.
Output
if
output
!=
"[TEST] error
\n
[TEST] warn
\n
"
{
if
output
!=
"[TEST] error
\n
[TEST] warn
\n
"
{
t
.
Error
(
"Expected logger output '[TEST] error
\\
n[TEST] warn
\\
n', got "
,
output
)
t
.
Error
(
"Expected logger output '[TEST] error
\\
n[TEST] warn
\\
n', got "
,
output
)
...
@@ -60,6 +62,8 @@ func TestLoggerPrintln(t *testing.T) {
...
@@ -60,6 +62,8 @@ func TestLoggerPrintln(t *testing.T) {
}
}
func
TestLoggerPrintf
(
t
*
testing
.
T
)
{
func
TestLoggerPrintf
(
t
*
testing
.
T
)
{
Reset
()
logger
:=
NewLogger
(
"TEST"
)
logger
:=
NewLogger
(
"TEST"
)
testLogSystem
:=
&
TestLogSystem
{
level
:
WarnLevel
}
testLogSystem
:=
&
TestLogSystem
{
level
:
WarnLevel
}
AddLogSystem
(
testLogSystem
)
AddLogSystem
(
testLogSystem
)
...
@@ -68,7 +72,6 @@ func TestLoggerPrintf(t *testing.T) {
...
@@ -68,7 +72,6 @@ func TestLoggerPrintf(t *testing.T) {
logger
.
Infof
(
"info"
)
logger
.
Infof
(
"info"
)
logger
.
Debugf
(
"debug"
)
logger
.
Debugf
(
"debug"
)
Flush
()
Flush
()
Reset
()
output
:=
testLogSystem
.
Output
output
:=
testLogSystem
.
Output
if
output
!=
"[TEST] error to { 2}
\n
[TEST] warn"
{
if
output
!=
"[TEST] error to { 2}
\n
[TEST] warn"
{
t
.
Error
(
"Expected logger output '[TEST] error to { 2}
\\
n[TEST] warn', got "
,
output
)
t
.
Error
(
"Expected logger output '[TEST] error to { 2}
\\
n[TEST] warn', got "
,
output
)
...
@@ -76,6 +79,8 @@ func TestLoggerPrintf(t *testing.T) {
...
@@ -76,6 +79,8 @@ func TestLoggerPrintf(t *testing.T) {
}
}
func
TestMultipleLogSystems
(
t
*
testing
.
T
)
{
func
TestMultipleLogSystems
(
t
*
testing
.
T
)
{
Reset
()
logger
:=
NewLogger
(
"TEST"
)
logger
:=
NewLogger
(
"TEST"
)
testLogSystem0
:=
&
TestLogSystem
{
level
:
ErrorLevel
}
testLogSystem0
:=
&
TestLogSystem
{
level
:
ErrorLevel
}
testLogSystem1
:=
&
TestLogSystem
{
level
:
WarnLevel
}
testLogSystem1
:=
&
TestLogSystem
{
level
:
WarnLevel
}
...
@@ -84,7 +89,6 @@ func TestMultipleLogSystems(t *testing.T) {
...
@@ -84,7 +89,6 @@ func TestMultipleLogSystems(t *testing.T) {
logger
.
Errorln
(
"error"
)
logger
.
Errorln
(
"error"
)
logger
.
Warnln
(
"warn"
)
logger
.
Warnln
(
"warn"
)
Flush
()
Flush
()
Reset
()
output0
:=
testLogSystem0
.
Output
output0
:=
testLogSystem0
.
Output
output1
:=
testLogSystem1
.
Output
output1
:=
testLogSystem1
.
Output
if
output0
!=
"[TEST] error
\n
"
{
if
output0
!=
"[TEST] error
\n
"
{
...
@@ -96,6 +100,8 @@ func TestMultipleLogSystems(t *testing.T) {
...
@@ -96,6 +100,8 @@ func TestMultipleLogSystems(t *testing.T) {
}
}
func
TestFileLogSystem
(
t
*
testing
.
T
)
{
func
TestFileLogSystem
(
t
*
testing
.
T
)
{
Reset
()
logger
:=
NewLogger
(
"TEST"
)
logger
:=
NewLogger
(
"TEST"
)
filename
:=
"test.log"
filename
:=
"test.log"
file
,
_
:=
os
.
OpenFile
(
filename
,
os
.
O_RDWR
|
os
.
O_CREATE
,
os
.
ModePerm
)
file
,
_
:=
os
.
OpenFile
(
filename
,
os
.
O_RDWR
|
os
.
O_CREATE
,
os
.
ModePerm
)
...
@@ -114,6 +120,8 @@ func TestFileLogSystem(t *testing.T) {
...
@@ -114,6 +120,8 @@ func TestFileLogSystem(t *testing.T) {
}
}
func
TestNoLogSystem
(
t
*
testing
.
T
)
{
func
TestNoLogSystem
(
t
*
testing
.
T
)
{
Reset
()
logger
:=
NewLogger
(
"TEST"
)
logger
:=
NewLogger
(
"TEST"
)
logger
.
Warnln
(
"warn"
)
logger
.
Warnln
(
"warn"
)
Flush
()
Flush
()
...
...
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