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
Léo-Paul Géneau
gitlab-ce
Commits
c6c9b37b
Commit
c6c9b37b
authored
Nov 03, 2017
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Clusters::Applications::Helm tests
parent
c0299ce4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
11 deletions
+118
-11
app/models/clusters/applications/helm.rb
app/models/clusters/applications/helm.rb
+5
-3
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+1
-1
app/models/clusters/concerns/application_status.rb
app/models/clusters/concerns/application_status.rb
+1
-1
spec/factories/clusters/applications/helm.rb
spec/factories/clusters/applications/helm.rb
+35
-0
spec/models/clusters/applications/helm_spec.rb
spec/models/clusters/applications/helm_spec.rb
+76
-6
No files found.
app/models/clusters/applications/helm.rb
View file @
c6c9b37b
...
...
@@ -3,8 +3,6 @@ module Clusters
class
Helm
<
ActiveRecord
::
Base
self
.
table_name
=
'clusters_applications_helm'
NAME
=
'helm'
.
freeze
include
::
Clusters
::
Concerns
::
ApplicationStatus
belongs_to
:cluster
,
class_name:
'Clusters::Cluster'
,
foreign_key: :cluster_id
...
...
@@ -13,8 +11,12 @@ module Clusters
validates
:cluster
,
presence:
true
def
self
.
application_name
self
.
to_s
.
demodulize
.
underscore
end
def
name
NAME
self
.
class
.
application_name
end
end
end
...
...
app/models/clusters/cluster.rb
View file @
c6c9b37b
...
...
@@ -5,7 +5,7 @@ module Clusters
self
.
table_name
=
'clusters'
APPLICATIONS
=
{
Clusters
::
Applications
::
Helm
::
NAME
=>
Clusters
::
Applications
::
Helm
Applications
::
Helm
.
application_name
=>
Applications
::
Helm
}.
freeze
belongs_to
:user
...
...
app/models/clusters/concerns/application_status.rb
View file @
c6c9b37b
...
...
@@ -24,7 +24,7 @@ module Clusters
end
event
:make_scheduled
do
transition
%i(installable errored)
=>
:scheduled
transition
any
-
[
:scheduled
]
=>
:scheduled
end
before_transition
any
=>
[
:scheduled
]
do
|
app_status
,
_
|
...
...
spec/factories/clusters/applications/helm.rb
0 → 100644
View file @
c6c9b37b
FactoryGirl
.
define
do
factory
:applications_helm
,
class:
Clusters
::
Applications
::
Helm
do
trait
:cluster
do
before
(
:create
)
do
|
app
,
_
|
app
.
cluster
=
create
(
:cluster
)
end
end
trait
:installable
do
cluster
status
0
end
trait
:scheduled
do
cluster
status
1
end
trait
:installing
do
cluster
status
2
end
trait
:installed
do
cluster
status
3
end
trait
:errored
do
cluster
status
(
-
1
)
status_reason
'something went wrong'
end
end
end
spec/models/clusters/applications/helm_spec.rb
View file @
c6c9b37b
require
'rails_helper'
require_relative
'../kubernetes_spec'
RSpec
.
describe
Clusters
::
Applications
::
Helm
,
type: :model
do
it_behaves_like
'a registered kubernetes app'
it
{
is_expected
.
to
belong_to
(
:cluster
)
}
it
{
is_expected
.
to
validate_presence_of
(
:cluster
)
}
it
{
is_expected
.
to
belong_to
(
:kubernetes_service
)
}
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
'#version'
do
it
'defaults to Gitlab::Kubernetes::Helm::HELM_VERSION'
do
expect
(
subject
.
version
).
to
eq
(
Gitlab
::
Kubernetes
::
Helm
::
HELM_VERSION
)
end
end
describe
'#status'
do
it
'defaults to :installable'
do
expect
(
subject
.
status_name
).
to
be
(
:installable
)
end
end
describe
'status state machine'
do
describe
'#make_installing'
do
subject
{
create
(
:applications_helm
,
:scheduled
)
}
it
'is installing'
do
subject
.
make_installing!
expect
(
subject
).
to
be_installing
end
end
describe
'#make_installed'
do
subject
{
create
(
:applications_helm
,
:installing
)
}
it
'is installed'
do
subject
.
make_installed
describe
'#cluster'
do
it
'is an alias to #kubernetes_service'
do
expect
(
subject
.
method
(
:cluster
).
original_name
).
to
eq
(
:kubernetes_service
)
expect
(
subject
).
to
be_installed
end
end
describe
'#make_errored'
do
subject
{
create
(
:applications_helm
,
: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
(
:applications_helm
,
:installable
)
}
it
'is scheduled'
do
subject
.
make_scheduled
expect
(
subject
).
to
be_scheduled
end
describe
'when was errored'
do
subject
{
create
(
:applications_helm
,
: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
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