Commit 3c5c6c2c authored by Thong Kuah's avatar Thong Kuah

Address BE review - re-arrange some specs

parent 6cba2698
...@@ -8,12 +8,11 @@ describe Clusters::Gcp::Kubernetes::CreateServiceAccountService do ...@@ -8,12 +8,11 @@ describe Clusters::Gcp::Kubernetes::CreateServiceAccountService do
let(:service) { described_class.new(kubeclient, rbac: rbac) } let(:service) { described_class.new(kubeclient, rbac: rbac) }
describe '#execute' do describe '#execute' do
subject { service.execute }
let(:rbac) { false } let(:rbac) { false }
let(:api_url) { 'http://111.111.111.111' } let(:api_url) { 'http://111.111.111.111' }
let(:username) { 'admin' } let(:username) { 'admin' }
let(:password) { 'xxx' } let(:password) { 'xxx' }
let(:kubeclient) do let(:kubeclient) do
Gitlab::Kubernetes::KubeClient.new( Gitlab::Kubernetes::KubeClient.new(
api_url, api_url,
...@@ -22,6 +21,8 @@ describe Clusters::Gcp::Kubernetes::CreateServiceAccountService do ...@@ -22,6 +21,8 @@ describe Clusters::Gcp::Kubernetes::CreateServiceAccountService do
) )
end end
subject { service.execute }
context 'when params are correct' do context 'when params are correct' do
before do before do
stub_kubeclient_discover(api_url) stub_kubeclient_discover(api_url)
......
# frozen_string_literal: true
require 'fast_spec_helper' require 'fast_spec_helper'
describe Clusters::Gcp::Kubernetes::FetchKubernetesTokenService do describe Clusters::Gcp::Kubernetes::FetchKubernetesTokenService do
describe '#execute' do describe '#execute' do
subject { described_class.new(kubeclient).execute }
let(:api_url) { 'http://111.111.111.111' } let(:api_url) { 'http://111.111.111.111' }
let(:username) { 'admin' } let(:username) { 'admin' }
let(:password) { 'xxx' } let(:password) { 'xxx' }
...@@ -16,6 +16,8 @@ describe Clusters::Gcp::Kubernetes::FetchKubernetesTokenService do ...@@ -16,6 +16,8 @@ describe Clusters::Gcp::Kubernetes::FetchKubernetesTokenService do
) )
end end
subject { described_class.new(kubeclient).execute }
context 'when params correct' do context 'when params correct' do
let(:decoded_token) { 'xxx.token.xxx' } let(:decoded_token) { 'xxx.token.xxx' }
let(:token) { Base64.encode64(decoded_token) } let(:token) { Base64.encode64(decoded_token) }
......
...@@ -32,10 +32,11 @@ end ...@@ -32,10 +32,11 @@ end
shared_examples 'create cluster service success' do shared_examples 'create cluster service success' do
before do before do
stub_feature_flags(rbac_clusters: false) stub_feature_flags(rbac_clusters: false)
expect(ClusterProvisionWorker).to receive(:perform_async)
end end
it 'creates a cluster object and performs a worker' do it 'creates a cluster object and performs a worker' do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { subject } expect { subject }
.to change { Clusters::Cluster.count }.by(1) .to change { Clusters::Cluster.count }.by(1)
.and change { Clusters::Providers::Gcp.count }.by(1) .and change { Clusters::Providers::Gcp.count }.by(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment