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
a1b535f9
Commit
a1b535f9
authored
Jun 07, 2016
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call Fatalf instead of Errorf when loading schema returns error
parent
812b87c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
schema_test.go
pkg/api/validation/schema_test.go
+8
-8
No files found.
pkg/api/validation/schema_test.go
View file @
a1b535f9
...
@@ -135,7 +135,7 @@ func TestLoad(t *testing.T) {
...
@@ -135,7 +135,7 @@ func TestLoad(t *testing.T) {
func
TestValidateOk
(
t
*
testing
.
T
)
{
func
TestValidateOk
(
t
*
testing
.
T
)
{
schema
,
err
:=
loadSchemaForTest
()
schema
,
err
:=
loadSchemaForTest
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
f
(
"Failed to load: %v"
,
err
)
t
.
Fatal
f
(
"Failed to load: %v"
,
err
)
}
}
tests
:=
[]
struct
{
tests
:=
[]
struct
{
obj
runtime
.
Object
obj
runtime
.
Object
...
@@ -167,7 +167,7 @@ func TestValidateOk(t *testing.T) {
...
@@ -167,7 +167,7 @@ func TestValidateOk(t *testing.T) {
func
TestValidateDifferentApiVersions
(
t
*
testing
.
T
)
{
func
TestValidateDifferentApiVersions
(
t
*
testing
.
T
)
{
schema
,
err
:=
loadSchemaForTest
()
schema
,
err
:=
loadSchemaForTest
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
f
(
"Failed to load: %v"
,
err
)
t
.
Fatal
f
(
"Failed to load: %v"
,
err
)
}
}
pod
:=
&
api
.
Pod
{}
pod
:=
&
api
.
Pod
{}
...
@@ -203,7 +203,7 @@ func TestValidateDifferentApiVersions(t *testing.T) {
...
@@ -203,7 +203,7 @@ func TestValidateDifferentApiVersions(t *testing.T) {
func
TestInvalid
(
t
*
testing
.
T
)
{
func
TestInvalid
(
t
*
testing
.
T
)
{
schema
,
err
:=
loadSchemaForTest
()
schema
,
err
:=
loadSchemaForTest
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
f
(
"Failed to load: %v"
,
err
)
t
.
Fatal
f
(
"Failed to load: %v"
,
err
)
}
}
tests
:=
[]
string
{
tests
:=
[]
string
{
"invalidPod1.json"
,
// command is a string, instead of []string.
"invalidPod1.json"
,
// command is a string, instead of []string.
...
@@ -227,7 +227,7 @@ func TestInvalid(t *testing.T) {
...
@@ -227,7 +227,7 @@ func TestInvalid(t *testing.T) {
func
TestValid
(
t
*
testing
.
T
)
{
func
TestValid
(
t
*
testing
.
T
)
{
schema
,
err
:=
loadSchemaForTest
()
schema
,
err
:=
loadSchemaForTest
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
f
(
"Failed to load: %v"
,
err
)
t
.
Fatal
f
(
"Failed to load: %v"
,
err
)
}
}
tests
:=
[]
string
{
tests
:=
[]
string
{
"validPod.yaml"
,
"validPod.yaml"
,
...
@@ -239,7 +239,7 @@ func TestValid(t *testing.T) {
...
@@ -239,7 +239,7 @@ func TestValid(t *testing.T) {
}
}
err
=
schema
.
ValidateBytes
(
pod
)
err
=
schema
.
ValidateBytes
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error %s, for pod %s"
,
err
,
pod
)
t
.
Errorf
(
"unexpected error
:
%s, for pod %s"
,
err
,
pod
)
}
}
}
}
}
}
...
@@ -274,7 +274,7 @@ func TestVersionRegex(t *testing.T) {
...
@@ -274,7 +274,7 @@ func TestVersionRegex(t *testing.T) {
// Tests that validation works fine when spec contains "type": "any" instead of "type": "object"
// Tests that validation works fine when spec contains "type": "any" instead of "type": "object"
// Ref: https://github.com/kubernetes/kubernetes/issues/24309
// Ref: https://github.com/kubernetes/kubernetes/issues/24309
func
TestType
O
Any
(
t
*
testing
.
T
)
{
func
TestTypeAny
(
t
*
testing
.
T
)
{
data
,
err
:=
readSwaggerFile
()
data
,
err
:=
readSwaggerFile
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"failed to read swagger file: %v"
,
err
)
t
.
Errorf
(
"failed to read swagger file: %v"
,
err
)
...
@@ -283,7 +283,7 @@ func TestTypeOAny(t *testing.T) {
...
@@ -283,7 +283,7 @@ func TestTypeOAny(t *testing.T) {
newData
:=
strings
.
Replace
(
string
(
data
),
`"type": "object"`
,
`"type": "any"`
,
-
1
)
newData
:=
strings
.
Replace
(
string
(
data
),
`"type": "object"`
,
`"type": "any"`
,
-
1
)
schema
,
err
:=
NewSwaggerSchemaFromBytes
([]
byte
(
newData
),
nil
)
schema
,
err
:=
NewSwaggerSchemaFromBytes
([]
byte
(
newData
),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
f
(
"Failed to load: %v"
,
err
)
t
.
Fatal
f
(
"Failed to load: %v"
,
err
)
}
}
tests
:=
[]
string
{
tests
:=
[]
string
{
"validPod.yaml"
,
"validPod.yaml"
,
...
@@ -304,7 +304,7 @@ func TestTypeOAny(t *testing.T) {
...
@@ -304,7 +304,7 @@ func TestTypeOAny(t *testing.T) {
}
}
err
=
schema
.
ValidateBytes
(
podBytes
)
err
=
schema
.
ValidateBytes
(
podBytes
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error %s, for pod %s"
,
err
,
string
(
podBytes
))
t
.
Errorf
(
"unexpected error
:
%s, for pod %s"
,
err
,
string
(
podBytes
))
}
}
}
}
}
}
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