blob: 40507a66c2dd736d45d30f383e36c93550195c07 (
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
83
84
85
86
87
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Ci::Config::Entry::PullPolicy, feature_category: :continuous_integration do
let(:entry) { described_class.new(config) }
describe '#value' do
subject(:value) { entry.value }
context 'when config value is nil' do
let(:config) { nil }
it { is_expected.to be_nil }
end
context 'when retry value is an empty array' do
let(:config) { [] }
it { is_expected.to eq(nil) }
end
context 'when retry value is string' do
let(:config) { "always" }
it { is_expected.to eq(%w[always]) }
end
context 'when retry value is array' do
let(:config) { %w[always if-not-present] }
it { is_expected.to eq(%w[always if-not-present]) }
end
end
describe 'validation' do
subject(:valid?) { entry.valid? }
context 'when retry value is nil' do
let(:config) { nil }
it { is_expected.to eq(false) }
end
context 'when retry value is an empty array' do
let(:config) { [] }
it { is_expected.to eq(false) }
end
context 'when retry value is a hash' do
let(:config) { {} }
it { is_expected.to eq(false) }
end
context 'when retry value is string' do
let(:config) { "always" }
it { is_expected.to eq(true) }
context 'when it is an invalid policy' do
let(:config) { "invalid" }
it { is_expected.to eq(false) }
end
context 'when it is an empty string' do
let(:config) { "" }
it { is_expected.to eq(false) }
end
end
context 'when retry value is array' do
let(:config) { %w[always if-not-present] }
it { is_expected.to eq(true) }
context 'when config contains an invalid policy' do
let(:config) { %w[always invalid] }
it { is_expected.to eq(false) }
end
end
end
end
|