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
a48c9f2f
Commit
a48c9f2f
authored
Feb 12, 2019
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kube-aggregator: split openapi tests
parent
b9fa35fa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
48 deletions
+73
-48
BUILD
.../kube-aggregator/pkg/controllers/openapi/aggregator/BUILD
+4
-1
downloader_test.go
...tor/pkg/controllers/openapi/aggregator/downloader_test.go
+0
-47
priority_test.go
...gator/pkg/controllers/openapi/aggregator/priority_test.go
+69
-0
No files found.
staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/BUILD
View file @
a48c9f2f
...
...
@@ -26,7 +26,10 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["aggregator_test.go"],
srcs = [
"downloader_test.go",
"priority_test.go",
],
embed = [":go_default_library"],
deps = [
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
...
...
staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/
aggregato
r_test.go
→
staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/
downloade
r_test.go
View file @
a48c9f2f
...
...
@@ -19,58 +19,12 @@ package aggregator
import
(
"fmt"
"net/http"
"reflect"
"testing"
"github.com/go-openapi/spec"
"github.com/stretchr/testify/assert"
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
)
func
newAPIServiceForTest
(
name
,
group
string
,
minGroupPriority
,
versionPriority
int32
)
apiregistration
.
APIService
{
r
:=
apiregistration
.
APIService
{}
r
.
Spec
.
Group
=
group
r
.
Spec
.
GroupPriorityMinimum
=
minGroupPriority
r
.
Spec
.
VersionPriority
=
versionPriority
r
.
Spec
.
Service
=
&
apiregistration
.
ServiceReference
{}
r
.
Name
=
name
return
r
}
func
assertSortedServices
(
t
*
testing
.
T
,
actual
[]
openAPISpecInfo
,
expectedNames
[]
string
)
{
actualNames
:=
[]
string
{}
for
_
,
a
:=
range
actual
{
actualNames
=
append
(
actualNames
,
a
.
apiService
.
Name
)
}
if
!
reflect
.
DeepEqual
(
actualNames
,
expectedNames
)
{
t
.
Errorf
(
"Expected %s got %s."
,
expectedNames
,
actualNames
)
}
}
func
TestAPIServiceSort
(
t
*
testing
.
T
)
{
list
:=
[]
openAPISpecInfo
{
{
apiService
:
newAPIServiceForTest
(
"FirstService"
,
"Group1"
,
10
,
5
),
spec
:
&
spec
.
Swagger
{},
},
{
apiService
:
newAPIServiceForTest
(
"SecondService"
,
"Group2"
,
15
,
3
),
spec
:
&
spec
.
Swagger
{},
},
{
apiService
:
newAPIServiceForTest
(
"FirstServiceInternal"
,
"Group1"
,
16
,
3
),
spec
:
&
spec
.
Swagger
{},
},
{
apiService
:
newAPIServiceForTest
(
"ThirdService"
,
"Group3"
,
15
,
3
),
spec
:
&
spec
.
Swagger
{},
},
}
sortByPriority
(
list
)
assertSortedServices
(
t
,
list
,
[]
string
{
"FirstService"
,
"FirstServiceInternal"
,
"SecondService"
,
"ThirdService"
})
}
type
handlerTest
struct
{
etag
string
data
[]
byte
...
...
@@ -136,7 +90,6 @@ func assertDownloadedSpec(actualSpec *spec.Swagger, actualEtag string, err error
}
func
TestDownloadOpenAPISpec
(
t
*
testing
.
T
)
{
s
:=
Downloader
{}
// Test with no eTag
...
...
staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/priority_test.go
0 → 100644
View file @
a48c9f2f
/*
Copyright 2017 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
aggregator
import
(
"reflect"
"testing"
"github.com/go-openapi/spec"
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
)
func
newAPIServiceForTest
(
name
,
group
string
,
minGroupPriority
,
versionPriority
int32
)
apiregistration
.
APIService
{
r
:=
apiregistration
.
APIService
{}
r
.
Spec
.
Group
=
group
r
.
Spec
.
GroupPriorityMinimum
=
minGroupPriority
r
.
Spec
.
VersionPriority
=
versionPriority
r
.
Spec
.
Service
=
&
apiregistration
.
ServiceReference
{}
r
.
Name
=
name
return
r
}
func
assertSortedServices
(
t
*
testing
.
T
,
actual
[]
openAPISpecInfo
,
expectedNames
[]
string
)
{
actualNames
:=
[]
string
{}
for
_
,
a
:=
range
actual
{
actualNames
=
append
(
actualNames
,
a
.
apiService
.
Name
)
}
if
!
reflect
.
DeepEqual
(
actualNames
,
expectedNames
)
{
t
.
Errorf
(
"Expected %s got %s."
,
expectedNames
,
actualNames
)
}
}
func
TestAPIServiceSort
(
t
*
testing
.
T
)
{
list
:=
[]
openAPISpecInfo
{
{
apiService
:
newAPIServiceForTest
(
"FirstService"
,
"Group1"
,
10
,
5
),
spec
:
&
spec
.
Swagger
{},
},
{
apiService
:
newAPIServiceForTest
(
"SecondService"
,
"Group2"
,
15
,
3
),
spec
:
&
spec
.
Swagger
{},
},
{
apiService
:
newAPIServiceForTest
(
"FirstServiceInternal"
,
"Group1"
,
16
,
3
),
spec
:
&
spec
.
Swagger
{},
},
{
apiService
:
newAPIServiceForTest
(
"ThirdService"
,
"Group3"
,
15
,
3
),
spec
:
&
spec
.
Swagger
{},
},
}
sortByPriority
(
list
)
assertSortedServices
(
t
,
list
,
[]
string
{
"FirstService"
,
"FirstServiceInternal"
,
"SecondService"
,
"ThirdService"
})
}
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