blob: 149fce33f43fb0594991e4579b9894b2567e2945 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe WebIdeTerminal do
let(:build) { create(:ci_build) }
subject { described_class.new(build) }
it 'returns the show_path of the build' do
expect(subject.show_path).to end_with("/ide_terminals/#{build.id}")
end
it 'returns the retry_path of the build' do
expect(subject.retry_path).to end_with("/ide_terminals/#{build.id}/retry")
end
it 'returns the cancel_path of the build' do
expect(subject.cancel_path).to end_with("/ide_terminals/#{build.id}/cancel")
end
it 'returns the terminal_path of the build' do
expect(subject.terminal_path).to end_with("/jobs/#{build.id}/terminal.ws")
end
it 'returns the proxy_websocket_path of the build' do
expect(subject.proxy_websocket_path).to end_with("/jobs/#{build.id}/proxy.ws")
end
describe 'services' do
let(:services_with_aliases) do
{
services: [{ name: 'postgres', alias: 'postgres' },
{ name: 'docker:stable-dind', alias: 'docker' }]
}
end
before do
allow(build).to receive(:options).and_return(config)
end
context 'when image does not have an alias' do
let(:config) do
{ image: 'ruby:2.7' }.merge(services_with_aliases)
end
it 'returns services aliases' do
expect(subject.services).to eq %w(postgres docker)
end
end
context 'when both image and services have aliases' do
let(:config) do
{ image: { name: 'ruby:2.7', alias: 'ruby' } }.merge(services_with_aliases)
end
it 'returns all aliases' do
expect(subject.services).to eq %w(postgres docker ruby)
end
end
context 'when image and services does not have any alias' do
let(:config) do
{ image: 'ruby:2.7', services: ['postgres'] }
end
it 'returns an empty array' do
expect(subject.services).to be_empty
end
end
context 'when no image nor services' do
let(:config) do
{ script: %w(echo) }
end
it 'returns an empty array' do
expect(subject.services).to be_empty
end
end
end
end
|