Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
97a655d2
Commit
97a655d2
authored
Feb 21, 2017
by
YuviPanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for ToJson
parent
5c52fe6a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
files_test.go
pkg/chartutil/files_test.go
+49
-0
No files found.
pkg/chartutil/files_test.go
View file @
97a655d2
...
...
@@ -141,3 +141,52 @@ one:
t
.
Fatal
(
"Expected parser error"
)
}
}
func
TestToJson
(
t
*
testing
.
T
)
{
expect
:=
"{
\"
foo
\"
:
\"
bar
\"
}"
v
:=
struct
{
Foo
string
`json:"foo"`
}{
Foo
:
"bar"
,
}
if
got
:=
ToJson
(
v
);
got
!=
expect
{
t
.
Errorf
(
"Expected %q, got %q"
,
expect
,
got
)
}
}
func
TestFromJson
(
t
*
testing
.
T
)
{
doc
:=
`{
"hello": "world",
"one": {
"two": "three"
}
}
`
dict
:=
FromJson
(
doc
)
if
err
,
ok
:=
dict
[
"Error"
];
ok
{
t
.
Fatalf
(
"Parse error: %s"
,
err
)
}
if
len
(
dict
)
!=
2
{
t
.
Fatal
(
"expected two elements."
)
}
world
:=
dict
[
"hello"
]
if
world
.
(
string
)
!=
"world"
{
t
.
Fatal
(
"Expected the world. Is that too much to ask?"
)
}
// This should fail because we don't currently support lists:
doc2
:=
`
[
"one",
"two",
"three"
]
`
dict
=
FromJson
(
doc2
)
if
_
,
ok
:=
dict
[
"Error"
];
!
ok
{
t
.
Fatal
(
"Expected parser error"
)
}
}
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