2017-11-02 06:14:10 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-11-02 10:10:46 -04:00
|
|
|
RSpec.describe Clusters::Applications::Helm, type: :model do
|
2017-11-03 14:20:29 -04:00
|
|
|
it { is_expected.to belong_to(:cluster) }
|
|
|
|
it { is_expected.to validate_presence_of(:cluster) }
|
2017-11-02 06:14:10 -04:00
|
|
|
|
2017-11-03 14:20:29 -04:00
|
|
|
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
|
2017-11-07 03:34:07 -05:00
|
|
|
subject { create(:cluster_applications_helm, :scheduled) }
|
2017-11-03 14:20:29 -04:00
|
|
|
|
|
|
|
it 'is installing' do
|
|
|
|
subject.make_installing!
|
|
|
|
|
|
|
|
expect(subject).to be_installing
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#make_installed' do
|
2017-11-07 03:34:07 -05:00
|
|
|
subject { create(:cluster_applications_helm, :installing) }
|
2017-11-03 14:20:29 -04:00
|
|
|
|
|
|
|
it 'is installed' do
|
|
|
|
subject.make_installed
|
|
|
|
|
|
|
|
expect(subject).to be_installed
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#make_errored' do
|
2017-11-07 03:34:07 -05:00
|
|
|
subject { create(:cluster_applications_helm, :installing) }
|
2017-11-03 14:20:29 -04:00
|
|
|
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
|
2017-11-07 03:34:07 -05:00
|
|
|
subject { create(:cluster_applications_helm, :installable) }
|
2017-11-03 14:20:29 -04:00
|
|
|
|
|
|
|
it 'is scheduled' do
|
|
|
|
subject.make_scheduled
|
|
|
|
|
|
|
|
expect(subject).to be_scheduled
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when was errored' do
|
2017-11-07 03:34:07 -05:00
|
|
|
subject { create(:cluster_applications_helm, :errored) }
|
2017-11-03 14:20:29 -04:00
|
|
|
|
|
|
|
it 'clears #status_reason' do
|
|
|
|
expect(subject.status_reason).not_to be_nil
|
|
|
|
|
|
|
|
subject.make_scheduled!
|
2017-11-02 06:14:10 -04:00
|
|
|
|
2017-11-03 14:20:29 -04:00
|
|
|
expect(subject.status_reason).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2017-11-02 06:14:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|