|
29 | 29 | ]
|
30 | 30 |
|
31 | 31 | it 'resolves the latest version if no candidate is supplied' do
|
32 |
| - expect(JavaBuildpack::VersionResolver.resolve(nil, VERSIONS)).to eq('2.0.0') |
33 |
| - expect(JavaBuildpack::VersionResolver.resolve('', VERSIONS)).to eq('2.0.0') |
| 32 | + expect(JavaBuildpack::VersionResolver.resolve(nil, nil, VERSIONS)).to eq('2.0.0') |
| 33 | + expect(JavaBuildpack::VersionResolver.resolve('', nil, VERSIONS)).to eq('2.0.0') |
| 34 | + expect(JavaBuildpack::VersionResolver.resolve(nil, '', VERSIONS)).to eq('2.0.0') |
| 35 | + expect(JavaBuildpack::VersionResolver.resolve('', '', VERSIONS)).to eq('2.0.0') |
| 36 | + end |
| 37 | + |
| 38 | + it 'resolves the default version if no candidate is supplied' do |
| 39 | + expect(JavaBuildpack::VersionResolver.resolve(nil, '1.6.0_+', VERSIONS)).to eq('1.6.0_27') |
| 40 | + expect(JavaBuildpack::VersionResolver.resolve('', '1.6.0_+', VERSIONS)).to eq('1.6.0_27') |
34 | 41 | end
|
35 | 42 |
|
36 | 43 | it 'resolves a wildcard major version' do
|
37 |
| - expect(JavaBuildpack::VersionResolver.resolve('+', VERSIONS)).to eq('2.0.0') |
| 44 | + expect(JavaBuildpack::VersionResolver.resolve('+', nil, VERSIONS)).to eq('2.0.0') |
38 | 45 | end
|
39 | 46 |
|
40 | 47 | it 'resolves a wildcard minor version' do
|
41 |
| - expect(JavaBuildpack::VersionResolver.resolve('1.+', VERSIONS)).to eq('1.8.0_05') |
| 48 | + expect(JavaBuildpack::VersionResolver.resolve('1.+', nil, VERSIONS)).to eq('1.8.0_05') |
42 | 49 | end
|
43 | 50 |
|
44 | 51 | it 'resolves a wildcard micro version' do
|
45 |
| - expect(JavaBuildpack::VersionResolver.resolve('1.6.+', VERSIONS)).to eq('1.6.1_14') |
| 52 | + expect(JavaBuildpack::VersionResolver.resolve('1.6.+', nil, VERSIONS)).to eq('1.6.1_14') |
46 | 53 | end
|
47 | 54 |
|
48 | 55 | it 'resolves a wildcard qualifier' do
|
49 |
| - expect(JavaBuildpack::VersionResolver.resolve('1.6.0_+', VERSIONS)).to eq('1.6.0_27') |
50 |
| - expect(JavaBuildpack::VersionResolver.resolve('1.8.0_+', VERSIONS)).to eq('1.8.0_05') |
| 56 | + expect(JavaBuildpack::VersionResolver.resolve('1.6.0_+', nil, VERSIONS)).to eq('1.6.0_27') |
| 57 | + expect(JavaBuildpack::VersionResolver.resolve('1.8.0_+', nil, VERSIONS)).to eq('1.8.0_05') |
51 | 58 | end
|
52 | 59 |
|
53 | 60 | it 'resolves a non-wildcard version' do
|
54 |
| - expect(JavaBuildpack::VersionResolver.resolve('1.6.0_26', VERSIONS)).to eq('1.6.0_26') |
55 |
| - expect(JavaBuildpack::VersionResolver.resolve('2.0.0', VERSIONS)).to eq('2.0.0') |
| 61 | + expect(JavaBuildpack::VersionResolver.resolve('1.6.0_26', nil, VERSIONS)).to eq('1.6.0_26') |
| 62 | + expect(JavaBuildpack::VersionResolver.resolve('2.0.0', nil, VERSIONS)).to eq('2.0.0') |
56 | 63 | end
|
57 | 64 |
|
58 | 65 | it 'resolves a non-digit qualifier' do
|
59 |
| - expect(JavaBuildpack::VersionResolver.resolve('1.8.0_M-7', VERSIONS)).to eq('1.8.0_M-7') |
| 66 | + expect(JavaBuildpack::VersionResolver.resolve('1.8.0_M-7', nil, VERSIONS)).to eq('1.8.0_M-7') |
60 | 67 | end
|
61 | 68 |
|
62 | 69 | it 'should order qualifiers correctly' do
|
63 |
| - expect(JavaBuildpack::VersionResolver.resolve('1.7.0_+', ['1.7.0_28', '1.7.0_28a'])).to eq('1.7.0_28a') |
| 70 | + expect(JavaBuildpack::VersionResolver.resolve('1.7.0_+', nil, ['1.7.0_28', '1.7.0_28a'])).to eq('1.7.0_28a') |
64 | 71 | end
|
65 | 72 |
|
66 | 73 | it 'should raise an exception when the major version is not numeric' do
|
67 |
| - expect { JavaBuildpack::VersionResolver.resolve('A', VERSIONS) }.to raise_error |
| 74 | + expect { JavaBuildpack::VersionResolver.resolve('A', nil, VERSIONS) }.to raise_error |
68 | 75 | end
|
69 | 76 |
|
70 | 77 | it 'should raise an exception when the minor version is not numeric' do
|
71 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.A', VERSIONS) }.to raise_error |
72 |
| - expect { JavaBuildpack::VersionResolver.resolve('1..0', VERSIONS) }.to raise_error |
| 78 | + expect { JavaBuildpack::VersionResolver.resolve('1.A', nil, VERSIONS) }.to raise_error |
| 79 | + expect { JavaBuildpack::VersionResolver.resolve('1..0', nil, VERSIONS) }.to raise_error |
73 | 80 | end
|
74 | 81 |
|
75 | 82 | it 'should raise an exception when the micro version is not numeric' do
|
76 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.A', VERSIONS) }.to raise_error |
77 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6..', VERSIONS) }.to raise_error |
78 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6_26', VERSIONS) }.to raise_error |
| 83 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.A', nil, VERSIONS) }.to raise_error |
| 84 | + expect { JavaBuildpack::VersionResolver.resolve('1.6..', nil, VERSIONS) }.to raise_error |
| 85 | + expect { JavaBuildpack::VersionResolver.resolve('1.6_26', nil, VERSIONS) }.to raise_error |
79 | 86 | end
|
80 | 87 |
|
81 | 88 | it 'should raise an exception if no version can be resolved' do
|
82 |
| - expect { JavaBuildpack::VersionResolver.resolve('2.1.0', VERSIONS) }.to raise_error |
| 89 | + expect { JavaBuildpack::VersionResolver.resolve('2.1.0', nil, VERSIONS) }.to raise_error |
83 | 90 | end
|
84 | 91 |
|
85 | 92 | it 'should raise an exception when major version is not legal' do
|
86 |
| - expect { JavaBuildpack::VersionResolver.resolve('1+', VERSIONS) }.to raise_error |
| 93 | + expect { JavaBuildpack::VersionResolver.resolve('1+', nil, VERSIONS) }.to raise_error |
87 | 94 | end
|
88 | 95 |
|
89 | 96 | it 'should raise an exception when minor version is not legal' do
|
90 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6+', VERSIONS) }.to raise_error |
| 97 | + expect { JavaBuildpack::VersionResolver.resolve('1.6+', nil, VERSIONS) }.to raise_error |
91 | 98 | end
|
92 | 99 |
|
93 | 100 | it 'should raise an exception when micro version is not legal' do
|
94 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.0+', VERSIONS) }.to raise_error |
| 101 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.0+', nil, VERSIONS) }.to raise_error |
95 | 102 | end
|
96 | 103 |
|
97 | 104 | it 'should raise an exception when qualifier version is not legal' do
|
98 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.0_05+', VERSIONS) }.to raise_error |
| 105 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.0_05+', nil, VERSIONS) }.to raise_error |
99 | 106 | end
|
100 | 107 |
|
101 | 108 | it 'should raise an exception when the qualifier is not letter, number, or hyphen' do
|
102 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.0_?', VERSIONS) }.to raise_error |
103 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.0__5', VERSIONS) }.to raise_error |
104 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.0_A.', VERSIONS) }.to raise_error |
| 109 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.0_?', nil, VERSIONS) }.to raise_error |
| 110 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.0__5', nil, VERSIONS) }.to raise_error |
| 111 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.0_A.', nil, VERSIONS) }.to raise_error |
105 | 112 | end
|
106 | 113 |
|
107 | 114 | it 'should raise an exception when a major version wildcard is folowed by anything' do
|
108 |
| - expect { JavaBuildpack::VersionResolver.resolve('+.6.0_26', VERSIONS) }.to raise_error |
| 115 | + expect { JavaBuildpack::VersionResolver.resolve('+.6.0_26', nil, VERSIONS) }.to raise_error |
109 | 116 | end
|
110 | 117 |
|
111 | 118 | it 'should raise an exception when a minor version wildcard is folowed by anything' do
|
112 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.+.0_26', VERSIONS) }.to raise_error |
| 119 | + expect { JavaBuildpack::VersionResolver.resolve('1.+.0_26', nil, VERSIONS) }.to raise_error |
113 | 120 | end
|
114 | 121 |
|
115 | 122 | it 'should raise an exception when a micro version wildcard is folowed by anything' do
|
116 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.+_26', VERSIONS) }.to raise_error |
| 123 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.+_26', nil, VERSIONS) }.to raise_error |
117 | 124 | end
|
118 | 125 |
|
119 | 126 | it 'should raise an exception when too many components are specified' do
|
120 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.0.25', VERSIONS) }.to raise_error |
121 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.0.25_27', VERSIONS) }.to raise_error |
| 127 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.0.25', nil, VERSIONS) }.to raise_error |
| 128 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.0.25_27', nil, VERSIONS) }.to raise_error |
122 | 129 | end
|
123 | 130 |
|
124 | 131 | it 'should raise an exception when not enough components are specified' do
|
125 |
| - expect { JavaBuildpack::VersionResolver.resolve('_25', VERSIONS) }.to raise_error |
| 132 | + expect { JavaBuildpack::VersionResolver.resolve('_25', nil, VERSIONS) }.to raise_error |
126 | 133 | end
|
127 | 134 |
|
128 | 135 | it 'should raise an exception when a wildcard is specified in the versions collection' do
|
129 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.6.0_25', ['+']) }.to raise_error |
| 136 | + expect { JavaBuildpack::VersionResolver.resolve('1.6.0_25', nil, ['+']) }.to raise_error |
130 | 137 | end
|
131 | 138 |
|
132 | 139 | it 'should raise an exception when a version ends with a component separator' do
|
133 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.', ['1.']) }.to raise_error |
134 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.7.', ['1.7.']) }.to raise_error |
135 |
| - expect { JavaBuildpack::VersionResolver.resolve('1.7.0_', ['1.7.0_']) }.to raise_error |
| 140 | + expect { JavaBuildpack::VersionResolver.resolve('1.', nil, ['1.']) }.to raise_error |
| 141 | + expect { JavaBuildpack::VersionResolver.resolve('1.7.', nil, ['1.7.']) }.to raise_error |
| 142 | + expect { JavaBuildpack::VersionResolver.resolve('1.7.0_', nil, ['1.7.0_']) }.to raise_error |
136 | 143 | end
|
137 | 144 |
|
138 | 145 | end
|
0 commit comments