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
b3304c49
Commit
b3304c49
authored
Mar 05, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use deep spew in serialization test & go obj diff
parent
cee14ab5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
serialization_test.go
pkg/api/serialization_test.go
+6
-3
diff.go
pkg/util/diff.go
+3
-2
No files found.
pkg/api/serialization_test.go
View file @
b3304c49
...
@@ -32,6 +32,7 @@ import (
...
@@ -32,6 +32,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/davecgh/go-spew/spew"
flag
"github.com/spf13/pflag"
flag
"github.com/spf13/pflag"
)
)
...
@@ -52,20 +53,22 @@ func fuzzInternalObject(t *testing.T, forVersion string, item runtime.Object, se
...
@@ -52,20 +53,22 @@ func fuzzInternalObject(t *testing.T, forVersion string, item runtime.Object, se
}
}
func
roundTrip
(
t
*
testing
.
T
,
codec
runtime
.
Codec
,
item
runtime
.
Object
)
{
func
roundTrip
(
t
*
testing
.
T
,
codec
runtime
.
Codec
,
item
runtime
.
Object
)
{
printer
:=
spew
.
ConfigState
{
DisableMethods
:
true
}
name
:=
reflect
.
TypeOf
(
item
)
.
Elem
()
.
Name
()
name
:=
reflect
.
TypeOf
(
item
)
.
Elem
()
.
Name
()
data
,
err
:=
codec
.
Encode
(
item
)
data
,
err
:=
codec
.
Encode
(
item
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"%v: %v (%
#v)"
,
name
,
err
,
item
)
t
.
Errorf
(
"%v: %v (%
s)"
,
name
,
err
,
printer
.
Sprintf
(
"%#v"
,
item
)
)
return
return
}
}
obj2
,
err
:=
codec
.
Decode
(
data
)
obj2
,
err
:=
codec
.
Decode
(
data
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"0: %v: %v
\n
Codec: %v
\n
Data: %s
\n
Source: %#v"
,
name
,
err
,
codec
,
string
(
data
),
item
)
t
.
Errorf
(
"0: %v: %v
\n
Codec: %v
\n
Data: %s
\n
Source: %#v"
,
name
,
err
,
codec
,
string
(
data
),
printer
.
Sprintf
(
"%#v"
,
item
)
)
return
return
}
}
if
!
api
.
Semantic
.
DeepEqual
(
item
,
obj2
)
{
if
!
api
.
Semantic
.
DeepEqual
(
item
,
obj2
)
{
t
.
Errorf
(
"1: %v: diff: %v
\n
Codec: %v
\n
Data: %s
\n
Source: %#v
\n
Final: %#v"
,
name
,
util
.
ObjectGoPrintDiff
(
item
,
obj2
),
codec
,
string
(
data
),
item
,
obj2
)
t
.
Errorf
(
"1: %v: diff: %v
\n
Codec: %v
\n
Data: %s
\n
Source: %#v
\n
Final: %#v"
,
name
,
util
.
ObjectGoPrintDiff
(
item
,
obj2
),
codec
,
string
(
data
),
printer
.
Sprintf
(
"%#v"
,
item
),
printer
.
Sprintf
(
"%#v"
,
obj2
)
)
return
return
}
}
...
...
pkg/util/diff.go
View file @
b3304c49
...
@@ -67,9 +67,10 @@ func ObjectDiff(a, b interface{}) string {
...
@@ -67,9 +67,10 @@ func ObjectDiff(a, b interface{}) string {
// can't figure out why reflect.DeepEqual is returning false and nothing is
// can't figure out why reflect.DeepEqual is returning false and nothing is
// showing you differences. This will.
// showing you differences. This will.
func
ObjectGoPrintDiff
(
a
,
b
interface
{})
string
{
func
ObjectGoPrintDiff
(
a
,
b
interface
{})
string
{
s
:=
spew
.
ConfigState
{
DisableMethods
:
true
}
return
StringDiff
(
return
StringDiff
(
s
pew
.
Sprintf
(
"%#v"
,
a
),
s
.
Sprintf
(
"%#v"
,
a
),
s
pew
.
Sprintf
(
"%#v"
,
b
),
s
.
Sprintf
(
"%#v"
,
b
),
)
)
}
}
...
...
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