Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
51fa67e8
Commit
51fa67e8
authored
5 years ago
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up the creation of knative stubs
parent
dc24b4ab
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
44 deletions
+18
-44
spec/controllers/projects/serverless/functions_controller_spec.rb
...trollers/projects/serverless/functions_controller_spec.rb
+14
-42
spec/support/helpers/kubernetes_helpers.rb
spec/support/helpers/kubernetes_helpers.rb
+4
-2
No files found.
spec/controllers/projects/serverless/functions_controller_spec.rb
View file @
51fa67e8
...
...
@@ -121,39 +121,23 @@ describe Projects::Serverless::FunctionsController do
end
end
context
'on Knative 0.5'
do
context
'on Knative 0.5
.0
'
do
before
do
stub_kubeclient_service_pods
stub_reactive_cache
(
knative_services_finder
,
{
services:
kube_knative_services_body
(
legacy_knative:
true
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)[
"items"
],
pods:
kube_knative_pods_body
(
cluster
.
project
.
name
,
namespace
.
namespace
)[
"items"
]
},
*
knative_services_finder
.
cache_args
)
prepare_knative_stubs
(
'0.5.0'
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)
end
include_examples
'GET #show with valid data'
end
context
'on Knative 0.6'
do
context
'on Knative 0.6
.0
'
do
before
do
stub_kubeclient_service_pods
stub_reactive_cache
(
knative_services_finder
,
{
services:
kube_knative_services_body
(
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)[
"items"
],
pods:
kube_knative_pods_body
(
cluster
.
project
.
name
,
namespace
.
namespace
)[
"items"
]
},
*
knative_services_finder
.
cache_args
)
prepare_knative_stubs
(
'0.6.0'
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)
end
include_examples
'GET #show with valid data'
end
context
'on Knative 0.7'
do
context
'on Knative 0.7
.0
'
do
before
do
prepare_knative_stubs
(
'0.7.0'
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)
end
...
...
@@ -197,39 +181,23 @@ describe Projects::Serverless::FunctionsController do
end
end
context
'on Knative 0.5'
do
context
'on Knative 0.5
.0
'
do
before
do
stub_kubeclient_service_pods
stub_reactive_cache
(
knative_services_finder
,
{
services:
kube_knative_services_body
(
legacy_knative:
true
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)[
"items"
],
pods:
kube_knative_pods_body
(
cluster
.
project
.
name
,
namespace
.
namespace
)[
"items"
]
},
*
knative_services_finder
.
cache_args
)
prepare_knative_stubs
(
'0.5.0'
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)
end
include_examples
'GET #index with data'
end
context
'on Knative 0.6'
do
context
'on Knative 0.6
.0
'
do
before
do
stub_kubeclient_service_pods
stub_reactive_cache
(
knative_services_finder
,
{
services:
kube_knative_services_body
(
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)[
"items"
],
pods:
kube_knative_pods_body
(
cluster
.
project
.
name
,
namespace
.
namespace
)[
"items"
]
},
*
knative_services_finder
.
cache_args
)
prepare_knative_stubs
(
'0.6.0'
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)
end
include_examples
'GET #index with data'
end
context
'on Knative 0.7'
do
context
'on Knative 0.7
.0
'
do
before
do
prepare_knative_stubs
(
'0.7.0'
,
namespace:
namespace
.
namespace
,
name:
cluster
.
project
.
name
)
end
...
...
@@ -243,6 +211,10 @@ describe Projects::Serverless::FunctionsController do
case
version
when
'0.7.0'
knative_07_service
(
options
)
when
'0.6.0'
knative_06_service
(
options
)
when
'0.5.0'
knative_05_service
(
options
)
end
stub_kubeclient_service_pods
...
...
This diff is collapsed.
Click to expand it.
spec/support/helpers/kubernetes_helpers.rb
View file @
51fa67e8
...
...
@@ -322,7 +322,7 @@ module KubernetesHelpers
def
kube_knative_services_body
(
legacy_knative:
false
,
**
options
)
{
"kind"
=>
"List"
,
"items"
=>
[
legacy_knative
?
knative_05_service
(
options
)
:
k
ube
_service
(
options
)]
"items"
=>
[
legacy_knative
?
knative_05_service
(
options
)
:
k
native_06
_service
(
options
)]
}
end
...
...
@@ -398,7 +398,8 @@ module KubernetesHelpers
}
end
def
kube_service
(
name:
"kubetest"
,
namespace:
"default"
,
domain:
"example.com"
)
# noinspection RubyStringKeysInHashInspection
def
knative_06_service
(
name:
"kubetest"
,
namespace:
"default"
,
domain:
"example.com"
)
{
"metadata"
=>
{
"creationTimestamp"
=>
"2018-11-21T06:16:33Z"
,
...
...
@@ -474,6 +475,7 @@ module KubernetesHelpers
"podcount"
=>
0
}
end
# noinspection RubyStringKeysInHashInspection
def
knative_05_service
(
name:
"kubetest"
,
namespace:
"default"
,
domain:
"example.com"
)
{
"metadata"
=>
{
...
...
This diff is collapsed.
Click to expand it.
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