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
5416c313
Commit
5416c313
authored
Nov 04, 2016
by
yarntime@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add defaults test
parent
70a8ea58
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
0 deletions
+106
-0
.linted_packages
hack/.linted_packages
+1
-0
BUILD
pkg/apis/autoscaling/v1/BUILD
+13
-0
defaults_test.go
pkg/apis/autoscaling/v1/defaults_test.go
+91
-0
test_owners.csv
test/test_owners.csv
+1
-0
No files found.
hack/.linted_packages
View file @
5416c313
...
...
@@ -71,6 +71,7 @@ pkg/apis/authentication.k8s.io/install
pkg/apis/authentication/install
pkg/apis/authorization/install
pkg/apis/autoscaling/install
pkg/apis/autoscaling/v1
pkg/apis/batch/install
pkg/apis/batch/v1
pkg/apis/batch/v2alpha1
...
...
pkg/apis/autoscaling/v1/BUILD
View file @
5416c313
...
...
@@ -37,3 +37,16 @@ go_library(
"//vendor:github.com/ugorji/go/codec",
],
)
go_test(
name = "go_default_xtest",
srcs = ["defaults_test.go"],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/install:go_default_library",
"//pkg/apis/autoscaling/install:go_default_library",
"//pkg/apis/autoscaling/v1:go_default_library",
"//pkg/runtime:go_default_library",
],
)
pkg/apis/autoscaling/v1/defaults_test.go
0 → 100644
View file @
5416c313
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
v1_test
import
(
"reflect"
"testing"
"k8s.io/kubernetes/pkg/api"
_
"k8s.io/kubernetes/pkg/api/install"
_
"k8s.io/kubernetes/pkg/apis/autoscaling/install"
.
"k8s.io/kubernetes/pkg/apis/autoscaling/v1"
"k8s.io/kubernetes/pkg/runtime"
)
func
TestSetDefaultHPA
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
hpa
HorizontalPodAutoscaler
expectReplicas
int32
test
string
}{
{
hpa
:
HorizontalPodAutoscaler
{},
expectReplicas
:
1
,
test
:
"unspecified min replicas, use the default value"
,
},
{
hpa
:
HorizontalPodAutoscaler
{
Spec
:
HorizontalPodAutoscalerSpec
{
MinReplicas
:
newInt32
(
3
),
},
},
expectReplicas
:
3
,
test
:
"set min replicas to 3"
,
},
}
for
_
,
test
:=
range
tests
{
hpa
:=
&
test
.
hpa
obj2
:=
roundTrip
(
t
,
runtime
.
Object
(
hpa
))
hpa2
,
ok
:=
obj2
.
(
*
HorizontalPodAutoscaler
)
if
!
ok
{
t
.
Fatalf
(
"unexpected object: %v"
,
obj2
)
}
if
hpa2
.
Spec
.
MinReplicas
==
nil
{
t
.
Errorf
(
"unexpected nil MinReplicas"
)
}
else
if
test
.
expectReplicas
!=
*
hpa2
.
Spec
.
MinReplicas
{
t
.
Errorf
(
"expected: %d MinReplicas, got: %d"
,
test
.
expectReplicas
,
*
hpa2
.
Spec
.
MinReplicas
)
}
}
}
func
roundTrip
(
t
*
testing
.
T
,
obj
runtime
.
Object
)
runtime
.
Object
{
data
,
err
:=
runtime
.
Encode
(
api
.
Codecs
.
LegacyCodec
(
SchemeGroupVersion
),
obj
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
%#v"
,
err
,
obj
)
return
nil
}
obj2
,
err
:=
runtime
.
Decode
(
api
.
Codecs
.
UniversalDecoder
(),
data
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
Data: %s
\n
Source: %#v"
,
err
,
string
(
data
),
obj
)
return
nil
}
obj3
:=
reflect
.
New
(
reflect
.
TypeOf
(
obj
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
err
=
api
.
Scheme
.
Convert
(
obj2
,
obj3
,
nil
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
Source: %#v"
,
err
,
obj2
)
return
nil
}
return
obj3
}
func
newInt32
(
val
int32
)
*
int32
{
p
:=
new
(
int32
)
*
p
=
val
return
p
}
test/test_owners.csv
View file @
5416c313
...
...
@@ -513,6 +513,7 @@ k8s.io/kubernetes/pkg/apimachinery/registered,jlowdermilk,1
k8s.io/kubernetes/pkg/apis/abac/v0,liggitt,0
k8s.io/kubernetes/pkg/apis/apps/validation,derekwaynecarr,1
k8s.io/kubernetes/pkg/apis/authorization/validation,erictune,0
k8s.io/kubernetes/pkg/apis/autoscaling/v1,yarntime,0
k8s.io/kubernetes/pkg/apis/autoscaling/validation,mtaufen,1
k8s.io/kubernetes/pkg/apis/batch/v1,vishh,1
k8s.io/kubernetes/pkg/apis/batch/v2alpha1,jlowdermilk,1
...
...
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