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
55747ec1
Commit
55747ec1
authored
Dec 22, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate rubbish logs in pkg/conversion test
parent
1f26fa40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
converter_test.go
pkg/conversion/converter_test.go
+17
-11
No files found.
pkg/conversion/converter_test.go
View file @
55747ec1
...
...
@@ -26,6 +26,12 @@ import (
"github.com/google/gofuzz"
)
func
testLogger
(
t
*
testing
.
T
)
DebugLogger
{
// We don't set logger to eliminate rubbish logs in tests.
// If you want to switch it, simply switch it to: "return t"
return
nil
}
func
TestConverter_byteSlice
(
t
*
testing
.
T
)
{
c
:=
NewConverter
()
src
:=
[]
byte
{
1
,
2
,
3
}
...
...
@@ -77,7 +83,7 @@ func TestConverter_DefaultConvert(t *testing.T) {
Baz
int
}
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
c
.
nameFunc
=
func
(
t
reflect
.
Type
)
string
{
return
"MyType"
}
// Ensure conversion funcs can call DefaultConvert to get default behavior,
...
...
@@ -116,7 +122,7 @@ func TestConverter_DeepCopy(t *testing.T) {
Qux
map
[
string
]
string
}
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
foo
,
baz
:=
"foo"
,
"baz"
x
:=
A
{
...
...
@@ -159,7 +165,7 @@ func TestConverter_CallsRegisteredFunctions(t *testing.T) {
}
type
C
struct
{}
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
err
:=
c
.
RegisterConversionFunc
(
func
(
in
*
A
,
out
*
B
,
s
Scope
)
error
{
out
.
Bar
=
in
.
Foo
return
s
.
Convert
(
&
in
.
Baz
,
&
out
.
Baz
,
0
)
...
...
@@ -244,7 +250,7 @@ func TestConverter_MapsStringArrays(t *testing.T) {
Other
string
}
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
if
err
:=
c
.
RegisterConversionFunc
(
func
(
input
*
[]
string
,
out
*
string
,
s
Scope
)
error
{
if
len
(
*
input
)
==
0
{
*
out
=
""
...
...
@@ -297,7 +303,7 @@ func TestConverter_MapsStringArraysWithMappingKey(t *testing.T) {
Other
string
}
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
if
err
:=
c
.
RegisterConversionFunc
(
func
(
input
*
[]
string
,
out
*
string
,
s
Scope
)
error
{
if
len
(
*
input
)
==
0
{
*
out
=
""
...
...
@@ -356,7 +362,7 @@ func TestConverter_fuzz(t *testing.T) {
reflect
.
TypeOf
(
ExternalTestType2
{})
:
"TestType2"
,
}[
t
]
}
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
for
i
,
item
:=
range
table
{
for
j
:=
0
;
j
<
*
fuzzIters
;
j
++
{
...
...
@@ -386,7 +392,7 @@ func TestConverter_MapElemAddr(t *testing.T) {
A
map
[
string
]
string
}
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
err
:=
c
.
RegisterConversionFunc
(
func
(
in
*
int
,
out
*
string
,
s
Scope
)
error
{
*
out
=
fmt
.
Sprintf
(
"%v"
,
*
in
)
...
...
@@ -432,7 +438,7 @@ func TestConverter_tags(t *testing.T) {
A
string
`test:"bar"`
}
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
err
:=
c
.
RegisterConversionFunc
(
func
(
in
*
string
,
out
*
string
,
s
Scope
)
error
{
if
e
,
a
:=
"foo"
,
s
.
SrcTag
()
.
Get
(
"test"
);
e
!=
a
{
...
...
@@ -457,7 +463,7 @@ func TestConverter_meta(t *testing.T) {
type
Foo
struct
{
A
string
}
type
Bar
struct
{
A
string
}
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
checks
:=
0
err
:=
c
.
RegisterConversionFunc
(
func
(
in
*
Foo
,
out
*
Bar
,
s
Scope
)
error
{
...
...
@@ -566,7 +572,7 @@ func TestConverter_flags(t *testing.T) {
}
f
:=
fuzz
.
New
()
.
NilChance
(
.5
)
.
NumElements
(
0
,
100
)
c
:=
NewConverter
()
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
for
i
,
item
:=
range
table
{
for
j
:=
0
;
j
<
*
fuzzIters
;
j
++
{
...
...
@@ -620,7 +626,7 @@ func TestConverter_FieldRename(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error %v"
,
err
)
}
c
.
Debug
=
t
c
.
Debug
=
t
estLogger
(
t
)
aVal
:=
&
A
{
WeirdMeta
:
WeirdMeta
{
...
...
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