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
Jérome Perrin
gitlab-ce
Commits
389c9bfc
Commit
389c9bfc
authored
Nov 07, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for ingress
parent
e40021cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
0 deletions
+148
-0
spec/factories/clusters/applications/ingress.rb
spec/factories/clusters/applications/ingress.rb
+35
-0
spec/models/clusters/applications/ingress_spec.rb
spec/models/clusters/applications/ingress_spec.rb
+92
-0
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+21
-0
No files found.
spec/factories/clusters/applications/ingress.rb
0 → 100644
View file @
389c9bfc
FactoryGirl
.
define
do
factory
:cluster_applications_ingress
,
class:
Clusters
::
Applications
::
Ingress
do
cluster
factory:
%i(cluster provided_by_gcp)
trait
:not_installable
do
status
-
2
end
trait
:installable
do
status
0
end
trait
:scheduled
do
status
1
end
trait
:installing
do
status
2
end
trait
:installed
do
status
3
end
trait
:errored
do
status
(
-
1
)
status_reason
'something went wrong'
end
trait
:timeouted
do
installing
updated_at
ClusterWaitForAppInstallationWorker
::
TIMEOUT
.
ago
end
end
end
spec/models/clusters/applications/ingress_spec.rb
0 → 100644
View file @
389c9bfc
require
'rails_helper'
describe
Clusters
::
Applications
::
Ingress
do
it
{
is_expected
.
to
belong_to
(
:cluster
)
}
it
{
is_expected
.
to
validate_presence_of
(
:cluster
)
}
describe
'#name'
do
it
'is .application_name'
do
expect
(
subject
.
name
).
to
eq
(
described_class
.
application_name
)
end
it
'is recorded in Clusters::Cluster::APPLICATIONS'
do
expect
(
Clusters
::
Cluster
::
APPLICATIONS
[
subject
.
name
]).
to
eq
(
described_class
)
end
end
describe
'#status'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
)
}
subject
{
described_class
.
new
(
cluster:
cluster
)
}
it
'defaults to :not_installable'
do
expect
(
subject
.
status_name
).
to
be
(
:not_installable
)
end
context
'when application helm is defined'
do
before
do
create
(
:cluster_applications_ingress
,
cluster:
cluster
)
end
it
'defaults to :installable'
do
expect
(
subject
.
status_name
).
to
be
(
:installable
)
end
end
end
describe
'status state machine'
do
describe
'#make_installing'
do
subject
{
create
(
:cluster_applications_ingress
,
:scheduled
)
}
it
'is installing'
do
subject
.
make_installing!
expect
(
subject
).
to
be_installing
end
end
describe
'#make_installed'
do
subject
{
create
(
:cluster_applications_ingress
,
:installing
)
}
it
'is installed'
do
subject
.
make_installed
expect
(
subject
).
to
be_installed
end
end
describe
'#make_errored'
do
subject
{
create
(
:cluster_applications_ingress
,
:installing
)
}
let
(
:reason
)
{
'some errors'
}
it
'is errored'
do
subject
.
make_errored
(
reason
)
expect
(
subject
).
to
be_errored
expect
(
subject
.
status_reason
).
to
eq
(
reason
)
end
end
describe
'#make_scheduled'
do
subject
{
create
(
:cluster_applications_ingress
,
:installable
)
}
it
'is scheduled'
do
subject
.
make_scheduled
expect
(
subject
).
to
be_scheduled
end
describe
'when was errored'
do
subject
{
create
(
:cluster_applications_ingress
,
:errored
)
}
it
'clears #status_reason'
do
expect
(
subject
.
status_reason
).
not_to
be_nil
subject
.
make_scheduled!
expect
(
subject
.
status_reason
).
to
be_nil
end
end
end
end
end
spec/models/clusters/cluster_spec.rb
View file @
389c9bfc
...
...
@@ -178,4 +178,25 @@ describe Clusters::Cluster do
it
{
is_expected
.
to
be_nil
}
end
end
describe
'#applications'
do
set
(
:cluster
)
{
create
(
:cluster
)
}
subject
{
cluster
.
applications
}
context
'when none of applications are created'
do
it
'returns a list of a new objects'
do
is_expected
.
not_to
be_empty
end
end
context
'when applications are created'
do
let!
(
:helm
)
{
create
(
:cluster_applications_helm
,
cluster:
cluster
)
}
let!
(
:ingress
)
{
create
(
:cluster_applications_ingress
,
cluster:
cluster
)
}
it
'returns a list of created applications'
do
is_expected
.
to
contain_exactly
(
helm
,
ingress
)
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