Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 18:08:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 18:08:44 +0300
commitb9bac6dbf78a5a7976fba14aaeef96bdeb0da612 (patch)
treeffe277b562256f718b0818e8fd3c8fd8766d0269 /spec/lib/gitlab
parent8c4198cbe631278e87fee04157d23494fbb80cdb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/serverless/domain_spec.rb22
-rw-r--r--spec/lib/gitlab/serverless/function_uri_spec.rb81
-rw-r--r--spec/lib/gitlab/serverless/service_spec.rb10
3 files changed, 6 insertions, 107 deletions
diff --git a/spec/lib/gitlab/serverless/domain_spec.rb b/spec/lib/gitlab/serverless/domain_spec.rb
deleted file mode 100644
index ae5551977d4..00000000000
--- a/spec/lib/gitlab/serverless/domain_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe Gitlab::Serverless::Domain do
- describe '.generate_uuid' do
- it 'has 14 characters' do
- expect(described_class.generate_uuid.length).to eq(described_class::UUID_LENGTH)
- end
-
- it 'consists of only hexadecimal characters' do
- expect(described_class.generate_uuid).to match(/\A\h+\z/)
- end
-
- it 'uses random characters' do
- uuid = 'abcd1234567890'
-
- expect(SecureRandom).to receive(:hex).with(described_class::UUID_LENGTH / 2).and_return(uuid)
- expect(described_class.generate_uuid).to eq(uuid)
- end
- end
-end
diff --git a/spec/lib/gitlab/serverless/function_uri_spec.rb b/spec/lib/gitlab/serverless/function_uri_spec.rb
deleted file mode 100644
index cd4abeb89f5..00000000000
--- a/spec/lib/gitlab/serverless/function_uri_spec.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe Gitlab::Serverless::FunctionURI do
- let(:function) { 'test-function' }
- let(:domain) { 'serverless.gitlab.io' }
- let(:pages_domain) { create(:pages_domain, :instance_serverless, domain: domain) }
- let!(:cluster) { create(:serverless_domain_cluster, uuid: 'abcdef12345678', pages_domain: pages_domain) }
- let(:valid_cluster) { 'aba1cdef123456f278' }
- let(:invalid_cluster) { 'aba1cdef123456f178' }
- let!(:environment) { create(:environment, name: 'test') }
-
- let(:valid_uri) { "https://#{function}-#{valid_cluster}#{"%x" % environment.id}-#{environment.slug}.#{domain}" }
- let(:valid_fqdn) { "#{function}-#{valid_cluster}#{"%x" % environment.id}-#{environment.slug}.#{domain}" }
- let(:invalid_uri) { "https://#{function}-#{invalid_cluster}#{"%x" % environment.id}-#{environment.slug}.#{domain}" }
-
- shared_examples 'a valid FunctionURI class' do
- describe '#to_s' do
- it 'matches valid URI' do
- expect(subject.to_s).to eq valid_uri
- end
- end
-
- describe '#function' do
- it 'returns function' do
- expect(subject.function).to eq function
- end
- end
-
- describe '#cluster' do
- it 'returns cluster' do
- expect(subject.cluster).to eq cluster
- end
- end
-
- describe '#environment' do
- it 'returns environment' do
- expect(subject.environment).to eq environment
- end
- end
- end
-
- describe '.new' do
- context 'with valid arguments' do
- subject { described_class.new(function: function, cluster: cluster, environment: environment) }
-
- it_behaves_like 'a valid FunctionURI class'
- end
-
- context 'with invalid arguments' do
- subject { described_class.new(function: function, environment: environment) }
-
- it 'raises an exception' do
- expect { subject }.to raise_error(ArgumentError)
- end
- end
- end
-
- describe '.parse' do
- context 'with valid URI' do
- subject { described_class.parse(valid_uri) }
-
- it_behaves_like 'a valid FunctionURI class'
- end
-
- context 'with valid FQDN' do
- subject { described_class.parse(valid_fqdn) }
-
- it_behaves_like 'a valid FunctionURI class'
- end
-
- context 'with invalid URI' do
- subject { described_class.parse(invalid_uri) }
-
- it 'returns nil' do
- expect(subject).to be_nil
- end
- end
- end
-end
diff --git a/spec/lib/gitlab/serverless/service_spec.rb b/spec/lib/gitlab/serverless/service_spec.rb
index f618dd02cdb..6db8b9cd0ba 100644
--- a/spec/lib/gitlab/serverless/service_spec.rb
+++ b/spec/lib/gitlab/serverless/service_spec.rb
@@ -94,17 +94,19 @@ describe Gitlab::Serverless::Service do
end
describe '#url' do
+ let(:serverless_domain) { instance_double(::Serverless::Domain, uri: URI('https://proxy.example.com')) }
+
it 'returns proxy URL if cluster has serverless domain' do
# cluster = create(:cluster)
knative = create(:clusters_applications_knative, :installed, cluster: cluster)
create(:serverless_domain_cluster, clusters_applications_knative_id: knative.id)
service = Gitlab::Serverless::Service.new(attributes.merge('cluster' => cluster))
- expect(Gitlab::Serverless::FunctionURI).to receive(:new).with(
- function: service.name,
- cluster: service.cluster.serverless_domain,
+ expect(::Serverless::Domain).to receive(:new).with(
+ function_name: service.name,
+ serverless_domain_cluster: service.cluster.serverless_domain,
environment: service.environment
- ).and_return('https://proxy.example.com')
+ ).and_return(serverless_domain)
expect(service.url).to eq('https://proxy.example.com')
end