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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
2802b5bb
Commit
2802b5bb
authored
Nov 06, 2017
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ClusterApplicationEntity tests
parent
b893a858
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
20 deletions
+55
-20
app/serializers/cluster_application_entity.rb
app/serializers/cluster_application_entity.rb
+1
-1
app/serializers/cluster_entity.rb
app/serializers/cluster_entity.rb
+1
-1
spec/fixtures/api/schemas/cluster_status.json
spec/fixtures/api/schemas/cluster_status.json
+11
-15
spec/serializers/cluster_application_entity_spec.rb
spec/serializers/cluster_application_entity_spec.rb
+30
-0
spec/serializers/cluster_entity_spec.rb
spec/serializers/cluster_entity_spec.rb
+11
-2
spec/serializers/cluster_serializer_spec.rb
spec/serializers/cluster_serializer_spec.rb
+1
-1
No files found.
app/serializers/cluster_app_entity.rb
→
app/serializers/cluster_app
lication
_entity.rb
View file @
2802b5bb
class
ClusterAppEntity
<
Grape
::
Entity
class
ClusterApp
lication
Entity
<
Grape
::
Entity
expose
:name
expose
:name
expose
:status_name
,
as: :status
expose
:status_name
,
as: :status
expose
:status_reason
expose
:status_reason
...
...
app/serializers/cluster_entity.rb
View file @
2802b5bb
...
@@ -3,5 +3,5 @@ class ClusterEntity < Grape::Entity
...
@@ -3,5 +3,5 @@ class ClusterEntity < Grape::Entity
expose
:status_name
,
as: :status
expose
:status_name
,
as: :status
expose
:status_reason
expose
:status_reason
expose
:applications
,
using:
ClusterAppEntity
expose
:applications
,
using:
ClusterApp
lication
Entity
end
end
spec/fixtures/api/schemas/cluster_status.json
View file @
2802b5bb
{
{
"type"
:
"object"
,
"type"
:
"object"
,
"required"
:
[
"required"
:
[
"status"
"status"
,
"applications"
],
],
"properties"
:
{
"properties"
:
{
"status"
:
{
"type"
:
"string"
},
"status"
:
{
"type"
:
"string"
},
"status_reason"
:
{
"type"
:
[
"string"
,
"null"
]
},
"status_reason"
:
{
"type"
:
[
"string"
,
"null"
]
},
"applications"
:
{
"$ref"
:
"#/definitions/applications"
}
"applications"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"#/definitions/application_status"
}
}
},
},
"additionalProperties"
:
false
,
"additionalProperties"
:
false
,
"definitions"
:
{
"definitions"
:
{
"applications"
:
{
"application_status"
:
{
"type"
:
"object"
,
"additionalProperties"
:
false
,
"properties"
:
{
"helm"
:
{
"$ref"
:
"#/definitions/app_status"
},
"runner"
:
{
"$ref"
:
"#/definitions/app_status"
},
"ingress"
:
{
"$ref"
:
"#/definitions/app_status"
},
"prometheus"
:
{
"$ref"
:
"#/definitions/app_status"
}
}
},
"app_status"
:
{
"type"
:
"object"
,
"type"
:
"object"
,
"additionalProperties"
:
false
,
"additionalProperties"
:
false
,
"properties"
:
{
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"status"
:
{
"status"
:
{
"type"
:
{
"type"
:
{
"enum"
:
[
"enum"
:
[
"installable"
,
"installable"
,
"scheduled"
,
"installing"
,
"installing"
,
"installed"
,
"installed"
,
"error"
"error
ed
"
]
]
}
}
},
},
"status_reason"
:
{
"type"
:
[
"string"
,
"null"
]
}
"status_reason"
:
{
"type"
:
[
"string"
,
"null"
]
}
},
},
"required"
:
[
"status"
]
"required"
:
[
"
name"
,
"
status"
]
}
}
}
}
}
}
spec/serializers/cluster_application_entity_spec.rb
0 → 100644
View file @
2802b5bb
require
'spec_helper'
describe
ClusterApplicationEntity
do
describe
'#as_json'
do
let
(
:application
)
{
build
(
:applications_helm
)
}
subject
{
described_class
.
new
(
application
).
as_json
}
it
'has name'
do
expect
(
subject
[
:name
]).
to
eq
(
application
.
name
)
end
it
'has status'
do
expect
(
subject
[
:status
]).
to
eq
(
:installable
)
end
it
'has no status_reason'
do
expect
(
subject
[
:status_reason
]).
to
be_nil
end
context
'when application is errored'
do
let
(
:application
)
{
build
(
:applications_helm
,
:errored
)
}
it
'has corresponded data'
do
expect
(
subject
[
:status
]).
to
eq
(
:errored
)
expect
(
subject
[
:status_reason
]).
not_to
be_nil
expect
(
subject
[
:status_reason
]).
to
eq
(
application
.
status_reason
)
end
end
end
end
spec/serializers/cluster_entity_spec.rb
View file @
2802b5bb
...
@@ -35,8 +35,17 @@ describe ClusterEntity do
...
@@ -35,8 +35,17 @@ describe ClusterEntity do
end
end
end
end
it
'contains applications'
do
context
'when no application has been installed'
do
expect
(
subject
[
:applications
]).
to
eq
({})
let
(
:cluster
)
{
create
(
:cluster
)
}
subject
{
described_class
.
new
(
cluster
).
as_json
[
:applications
]}
it
'contains helm as installable'
do
expect
(
subject
).
not_to
be_empty
helm
=
subject
[
0
]
expect
(
helm
[
:name
]).
to
eq
(
'helm'
)
expect
(
helm
[
:status
]).
to
eq
(
:installable
)
end
end
end
end
end
end
end
spec/serializers/cluster_serializer_spec.rb
View file @
2802b5bb
...
@@ -9,7 +9,7 @@ describe ClusterSerializer do
...
@@ -9,7 +9,7 @@ describe ClusterSerializer do
let
(
:provider
)
{
create
(
:provider_gcp
,
:errored
)
}
let
(
:provider
)
{
create
(
:provider_gcp
,
:errored
)
}
it
'serializes only status'
do
it
'serializes only status'
do
expect
(
subject
.
keys
).
to
contain_exactly
(
:status
,
:status_reason
)
expect
(
subject
.
keys
).
to
contain_exactly
(
:status
,
:status_reason
,
:applications
)
end
end
end
end
...
...
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