solve 3.1.1 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,307 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Solutions when using the ruby solver" do
4
-
5
- before do
6
- Solve.engine = :ruby
7
- end
8
-
9
- it "chooses the correct artifact for the demands" do
10
- graph = Solve::Graph.new
11
- graph.artifact("mysql", "2.0.0")
12
- graph.artifact("mysql", "1.2.0")
13
- graph.artifact("nginx", "1.0.0").depends("mysql", "= 1.2.0")
14
-
15
- result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']])
16
-
17
- result.should eql("nginx" => "1.0.0", "mysql" => "1.2.0")
18
- end
19
-
20
- it "chooses the best artifact for the demands" do
21
- graph = Solve::Graph.new
22
- graph.artifact("mysql", "2.0.0")
23
- graph.artifact("mysql", "1.2.0")
24
- graph.artifact("nginx", "1.0.0").depends("mysql", ">= 1.2.0")
25
-
26
- result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']])
27
-
28
- result.should eql("nginx" => "1.0.0", "mysql" => "2.0.0")
29
- end
30
-
31
- it "raises NoSolutionError when a solution cannot be found" do
32
- graph = Solve::Graph.new
33
- graph.artifact("mysql", "1.2.0")
34
-
35
- lambda {
36
- Solve.it!(graph, ['mysql', '>= 2.0.0'])
37
- }.should raise_error(Solve::Errors::NoSolutionError)
38
- end
39
-
40
- it "find the correct solution when backtracking in variables introduced via demands" do
41
- graph = Solve::Graph.new
42
-
43
- graph.artifact("D", "1.2.0")
44
- graph.artifact("D", "1.3.0")
45
- graph.artifact("D", "1.4.0")
46
- graph.artifact("D", "2.0.0")
47
- graph.artifact("D", "2.1.0")
48
-
49
- graph.artifact("C", "2.0.0").depends("D", "= 1.2.0")
50
- graph.artifact("C", "2.1.0").depends("D", ">= 2.1.0")
51
- graph.artifact("C", "2.2.0").depends("D", "> 2.0.0")
52
-
53
- graph.artifact("B", "1.0.0").depends("D", "= 1.0.0")
54
- graph.artifact("B", "1.1.0").depends("D", "= 1.0.0")
55
- graph.artifact("B", "2.0.0").depends("D", ">= 1.3.0")
56
- graph.artifact("B", "2.1.0").depends("D", ">= 2.0.0")
57
-
58
- graph.artifact("A", "1.0.0").depends("B", "> 2.0.0")
59
- graph.artifact("A", "1.0.0").depends("C", "= 2.1.0")
60
- graph.artifact("A", "1.0.1").depends("B", "> 1.0.0")
61
- graph.artifact("A", "1.0.1").depends("C", "= 2.1.0")
62
- graph.artifact("A", "1.0.2").depends("B", "> 1.0.0")
63
- graph.artifact("A", "1.0.2").depends("C", "= 2.0.0")
64
-
65
- result = Solve.it!(graph, [['A', '~> 1.0.0'], ['D', ">= 2.0.0"]])
66
-
67
-
68
- result.should eql("A" => "1.0.1",
69
- "B" => "2.1.0",
70
- "C" => "2.1.0",
71
- "D" => "2.1.0")
72
- end
73
-
74
- it "rejects a circular dependency with a circular dep error" do
75
- graph = Solve::Graph.new
76
-
77
- graph.artifact("A", "1.0.0").depends("B", "1.0.0")
78
- graph.artifact("B", "1.0.0").depends("C", "1.0.0")
79
- graph.artifact("C", "1.0.0").depends("A", "1.0.0")
80
-
81
- expect { Solve.it!(graph, [["A", "1.0.0"]]) }.to raise_error(Solve::Errors::NoSolutionError)
82
- end
83
-
84
- it "rejects a p shaped depenency chain with a circular dep error" do
85
- graph = Solve::Graph.new
86
-
87
- graph.artifact("A", "1.0.0").depends("B", "1.0.0")
88
- graph.artifact("B", "1.0.0").depends("C", "1.0.0")
89
- graph.artifact("C", "1.0.0").depends("B", "1.0.0")
90
-
91
- expect { Solve.it!(graph, [["A", "1.0.0"]]) }.to raise_error(Solve::Errors::NoSolutionError)
92
- end
93
-
94
- it "finds the correct solution when there is a diamond shaped dependency" do
95
- graph = Solve::Graph.new
96
-
97
- graph.artifact("A", "1.0.0")
98
- .depends("B", "1.0.0")
99
- .depends("C", "1.0.0")
100
- graph.artifact("B", "1.0.0")
101
- .depends("D", "1.0.0")
102
- graph.artifact("C", "1.0.0")
103
- .depends("D", "1.0.0")
104
- graph.artifact("D", "1.0.0")
105
-
106
- result = Solve.it!(graph, [["A", "1.0.0"]])
107
-
108
- result.should eql("A" => "1.0.0",
109
- "B" => "1.0.0",
110
- "C" => "1.0.0",
111
- "D" => "1.0.0")
112
- end
113
-
114
- it "solves when packages and constraints have prerelease elements" do
115
- graph = Solve::Graph.new
116
-
117
- graph.artifact("A", "1.0.0")
118
- .depends("B", ">= 1.0.0-alpha")
119
- graph.artifact("B", "1.0.0-alpha")
120
- .depends("C", "1.0.0")
121
- graph.artifact("C", "1.0.0")
122
-
123
- result = Solve.it!(graph, [["A", "1.0.0"]])
124
-
125
- result.should eql("A" => "1.0.0",
126
- "B" => "1.0.0-alpha",
127
- "C" => "1.0.0")
128
-
129
- end
130
-
131
- it "solves when packages and constraints have build elements" do
132
- graph = Solve::Graph.new
133
-
134
- graph.artifact("A", "1.0.0")
135
- .depends("B", ">= 1.0.0+build")
136
- graph.artifact("B", "1.0.0+build")
137
- .depends("C", "1.0.0")
138
- graph.artifact("C", "1.0.0")
139
-
140
- result = Solve.it!(graph, [["A", "1.0.0"]])
141
-
142
- result.should eql("A" => "1.0.0",
143
- "B" => "1.0.0+build",
144
- "C" => "1.0.0")
145
-
146
- end
147
-
148
- it "fails with a self dependency" do
149
- graph = Solve::Graph.new
150
-
151
- graph.artifact("bottom", "1.0.0")
152
- graph.artifact("middle", "1.0.0").depends("top", "= 1.0.0").depends("middle")
153
-
154
- demands = [["bottom", "1.0.0"],["middle", "1.0.0"]]
155
-
156
- expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
157
- error.should be_a(Solve::Errors::NoSolutionError)
158
- }
159
- end
160
-
161
- it "gives an empty solution when there are no demands" do
162
- graph = Solve::Graph.new
163
- result = Solve.it!(graph, [])
164
- result.should eql({})
165
- end
166
-
167
- it "tries all combinations until it finds a solution" do
168
-
169
- graph = Solve::Graph.new
170
-
171
- graph.artifact("A", "1.0.0").depends("B", "~> 1.0.0")
172
- graph.artifact("A", "1.0.1").depends("B", "~> 1.0.0")
173
- graph.artifact("A", "1.0.2").depends("B", "~> 1.0.0")
174
-
175
- graph.artifact("B", "1.0.0").depends("C", "~> 1.0.0")
176
- graph.artifact("B", "1.0.1").depends("C", "~> 1.0.0")
177
- graph.artifact("B", "1.0.2").depends("C", "~> 1.0.0")
178
-
179
- graph.artifact("C", "1.0.0").depends("D", "1.0.0")
180
- graph.artifact("C", "1.0.1").depends("D", "1.0.0")
181
- graph.artifact("C", "1.0.2").depends("D", "1.0.0")
182
-
183
- # Note:
184
- # This test previously used two circular dependencies:
185
- # (D 1.0.0) -> A < 0.0.0
186
- # (D 0.0.0) -> A = 0.0.0
187
- # But Molinillo doesn't support circular dependencies at all.
188
-
189
- # ensure we can't find a solution in the above
190
- graph.artifact("D", "1.0.0").depends("E", "< 0.0.0")
191
-
192
- # Add a solution to the graph that should be reached only after all of the
193
- # others have been tried
194
- graph.artifact("A", "0.0.0").depends("B", "0.0.0")
195
- graph.artifact("B", "0.0.0").depends("C", "0.0.0")
196
- graph.artifact("C", "0.0.0").depends("D", "0.0.0")
197
- graph.artifact("D", "0.0.0")
198
-
199
- demands = [["A"]]
200
-
201
- result = Solve.it!(graph, demands)
202
-
203
- result.should eql({ "A" => "0.0.0",
204
- "B" => "0.0.0",
205
- "C" => "0.0.0",
206
- "D" => "0.0.0"})
207
-
208
- end
209
-
210
- it "correctly resolves when a resolution exists but it is not the latest" do
211
- graph = Solve::Graph.new
212
-
213
- graph.artifact("get-the-old-one", "1.0.0")
214
- .depends("locked-mid-1", ">= 0.0.0")
215
- .depends("locked-mid-2", ">= 0.0.0")
216
- graph.artifact("get-the-old-one", "0.5.0")
217
-
218
- graph.artifact("locked-mid-1", "2.0.0").depends("old-bottom", "= 2.0.0")
219
- graph.artifact("locked-mid-1", "1.3.0").depends("old-bottom", "= 0.5.0")
220
- graph.artifact("locked-mid-1", "1.0.0")
221
-
222
- graph.artifact("locked-mid-2", "2.0.0").depends("old-bottom", "= 2.1.0")
223
- graph.artifact("locked-mid-2", "1.4.0").depends("old-bottom", "= 0.5.0")
224
- graph.artifact("locked-mid-2", "1.0.0")
225
-
226
- graph.artifact("old-bottom", "2.1.0")
227
- graph.artifact("old-bottom", "2.0.0")
228
- graph.artifact("old-bottom", "1.0.0")
229
- graph.artifact("old-bottom", "0.5.0")
230
-
231
- demands = [["get-the-old-one"]]
232
-
233
- result = Solve.it!(graph, demands)
234
-
235
- # Note: Gecode solver is different. It picks:
236
- #
237
- # "get-the-old-one" => "1.0.0",
238
- # "locked-mid-1" => "1.0.0",
239
- # "locked-mid-2" => "2.0.0",
240
- # "old-bottom" => "2.1.0"
241
-
242
- result.should eql({
243
- "get-the-old-one" => "1.0.0",
244
- "locked-mid-1" => "2.0.0",
245
- "locked-mid-2" => "1.0.0",
246
- "old-bottom" => "2.0.0"
247
- })
248
- end
249
-
250
- describe "when options[:sorted] is true" do
251
- describe "with a simple list of dependencies" do
252
- it "returns a sorted list of dependencies" do
253
- graph = Solve::Graph.new
254
-
255
- graph.artifact("A", "1.0.0").depends("B", "= 1.0.0")
256
- graph.artifact("B", "1.0.0").depends("C", "= 1.0.0")
257
- graph.artifact("C", "1.0.0")
258
-
259
- demands = [["A"]]
260
-
261
- result = Solve.it!(graph, demands, { :sorted => true })
262
-
263
- result.should eql([
264
- ["C", "1.0.0"],
265
- ["B", "1.0.0"],
266
- ["A", "1.0.0"]
267
- ])
268
- end
269
- end
270
-
271
- # The order that the demands come in determines the order of artifacts
272
- # in the solver's variable_table. This must not determine the sort order
273
- describe "with a constraint that depends upon an earlier constrained artifact" do
274
- it "returns a sorted list of dependencies" do
275
- graph = Solve::Graph.new
276
-
277
- graph.artifact("B", "1.0.0").depends("A", "= 1.0.0")
278
- graph.artifact("A", "1.0.0").depends("C", "= 1.0.0")
279
- graph.artifact("C", "1.0.0")
280
-
281
- demands = [["A"],["B"]]
282
-
283
- result = Solve.it!(graph, demands, { :sorted => true } )
284
-
285
- result.should eql([
286
- ["C", "1.0.0"],
287
- ["A", "1.0.0"],
288
- ["B", "1.0.0"]
289
- ])
290
- end
291
- end
292
-
293
- describe "when the solution is cyclic" do
294
- it "raises a Solve::Errors::NoSolutionError because Molinillo doesn't support circular deps" do
295
- graph = Solve::Graph.new
296
-
297
- graph.artifact("A", "1.0.0").depends("B", "= 1.0.0")
298
- graph.artifact("B", "1.0.0").depends("C", "= 1.0.0")
299
- graph.artifact("C", "1.0.0").depends("A", "= 1.0.0")
300
-
301
- demands = [["A"]]
302
-
303
- expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error(Solve::Errors::NoSolutionError)
304
- end
305
- end
306
- end
307
- end
@@ -1,317 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Solutions", :gecode do
4
-
5
- before do
6
- Solve.engine = :gecode
7
- end
8
-
9
- it "chooses the correct artifact for the demands" do
10
- graph = Solve::Graph.new
11
- graph.artifact("mysql", "2.0.0")
12
- graph.artifact("mysql", "1.2.0")
13
- graph.artifact("nginx", "1.0.0").depends("mysql", "= 1.2.0")
14
-
15
- result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']])
16
-
17
- result.should eql("nginx" => "1.0.0", "mysql" => "1.2.0")
18
- end
19
-
20
- it "chooses the best artifact for the demands" do
21
- graph = Solve::Graph.new
22
- graph.artifact("mysql", "2.0.0")
23
- graph.artifact("mysql", "1.2.0")
24
- graph.artifact("nginx", "1.0.0").depends("mysql", ">= 1.2.0")
25
-
26
- result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']])
27
-
28
- result.should eql("nginx" => "1.0.0", "mysql" => "2.0.0")
29
- end
30
-
31
- it "raises NoSolutionError when a solution cannot be found" do
32
- graph = Solve::Graph.new
33
- graph.artifact("mysql", "1.2.0")
34
-
35
- lambda {
36
- Solve.it!(graph, ['mysql', '>= 2.0.0'])
37
- }.should raise_error(Solve::Errors::NoSolutionError)
38
- end
39
-
40
- it "find the correct solution when backtracking in variables introduced via demands" do
41
- graph = Solve::Graph.new
42
-
43
- graph.artifact("D", "1.2.0")
44
- graph.artifact("D", "1.3.0")
45
- graph.artifact("D", "1.4.0")
46
- graph.artifact("D", "2.0.0")
47
- graph.artifact("D", "2.1.0")
48
-
49
- graph.artifact("C", "2.0.0").depends("D", "= 1.2.0")
50
- graph.artifact("C", "2.1.0").depends("D", ">= 2.1.0")
51
- graph.artifact("C", "2.2.0").depends("D", "> 2.0.0")
52
-
53
- graph.artifact("B", "1.0.0").depends("D", "= 1.0.0")
54
- graph.artifact("B", "1.1.0").depends("D", "= 1.0.0")
55
- graph.artifact("B", "2.0.0").depends("D", ">= 1.3.0")
56
- graph.artifact("B", "2.1.0").depends("D", ">= 2.0.0")
57
-
58
- graph.artifact("A", "1.0.0").depends("B", "> 2.0.0")
59
- graph.artifact("A", "1.0.0").depends("C", "= 2.1.0")
60
- graph.artifact("A", "1.0.1").depends("B", "> 1.0.0")
61
- graph.artifact("A", "1.0.1").depends("C", "= 2.1.0")
62
- graph.artifact("A", "1.0.2").depends("B", "> 1.0.0")
63
- graph.artifact("A", "1.0.2").depends("C", "= 2.0.0")
64
-
65
- result = Solve.it!(graph, [['A', '~> 1.0.0'], ['D', ">= 2.0.0"]])
66
-
67
-
68
- result.should eql("A" => "1.0.1",
69
- "B" => "2.1.0",
70
- "C" => "2.1.0",
71
- "D" => "2.1.0")
72
- end
73
-
74
- it "finds the correct solution when there is a circular dependency" do
75
- graph = Solve::Graph.new
76
-
77
- graph.artifact("A", "1.0.0").depends("B", "1.0.0")
78
- graph.artifact("B", "1.0.0").depends("C", "1.0.0")
79
- graph.artifact("C", "1.0.0").depends("A", "1.0.0")
80
-
81
- result = Solve.it!(graph, [["A", "1.0.0"]])
82
-
83
- result.should eql("A" => "1.0.0",
84
- "B" => "1.0.0",
85
- "C" => "1.0.0")
86
- end
87
-
88
- it "finds the correct solution when there is a p shaped depenency chain" do
89
- graph = Solve::Graph.new
90
-
91
- graph.artifact("A", "1.0.0").depends("B", "1.0.0")
92
- graph.artifact("B", "1.0.0").depends("C", "1.0.0")
93
- graph.artifact("C", "1.0.0").depends("B", "1.0.0")
94
-
95
- result = Solve.it!(graph, [["A", "1.0.0"]])
96
-
97
- result.should eql("A" => "1.0.0",
98
- "B" => "1.0.0",
99
- "C" => "1.0.0")
100
- end
101
-
102
- it "finds the correct solution when there is a diamond shaped dependency" do
103
- graph = Solve::Graph.new
104
-
105
- graph.artifact("A", "1.0.0")
106
- .depends("B", "1.0.0")
107
- .depends("C", "1.0.0")
108
- graph.artifact("B", "1.0.0")
109
- .depends("D", "1.0.0")
110
- graph.artifact("C", "1.0.0")
111
- .depends("D", "1.0.0")
112
- graph.artifact("D", "1.0.0")
113
-
114
- result = Solve.it!(graph, [["A", "1.0.0"]])
115
-
116
- result.should eql("A" => "1.0.0",
117
- "B" => "1.0.0",
118
- "C" => "1.0.0",
119
- "D" => "1.0.0")
120
- end
121
-
122
- it "solves when packages and constraints have prerelease elements" do
123
- graph = Solve::Graph.new
124
-
125
- graph.artifact("A", "1.0.0")
126
- .depends("B", ">= 1.0.0-alpha")
127
- graph.artifact("B", "1.0.0-alpha")
128
- .depends("C", "1.0.0")
129
- graph.artifact("C", "1.0.0")
130
-
131
- result = Solve.it!(graph, [["A", "1.0.0"]])
132
-
133
- result.should eql("A" => "1.0.0",
134
- "B" => "1.0.0-alpha",
135
- "C" => "1.0.0")
136
-
137
- end
138
-
139
- it "solves when packages and constraints have build elements" do
140
- graph = Solve::Graph.new
141
-
142
- graph.artifact("A", "1.0.0")
143
- .depends("B", ">= 1.0.0+build")
144
- graph.artifact("B", "1.0.0+build")
145
- .depends("C", "1.0.0")
146
- graph.artifact("C", "1.0.0")
147
-
148
- result = Solve.it!(graph, [["A", "1.0.0"]])
149
-
150
- result.should eql("A" => "1.0.0",
151
- "B" => "1.0.0+build",
152
- "C" => "1.0.0")
153
-
154
- end
155
-
156
- it "fails with a self dependency" do
157
- graph = Solve::Graph.new
158
-
159
- graph.artifact("bottom", "1.0.0")
160
- graph.artifact("middle", "1.0.0").depends("top", "= 1.0.0").depends("middle")
161
-
162
- demands = [["bottom", "1.0.0"],["middle", "1.0.0"]]
163
-
164
- expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
165
- error.should be_a(Solve::Errors::NoSolutionError)
166
- }
167
- end
168
-
169
- it "gives an empty solution when there are no demands" do
170
- graph = Solve::Graph.new
171
- result = Solve.it!(graph, [])
172
- result.should eql({})
173
- end
174
-
175
- it "tries all combinations until it finds a solution" do
176
-
177
- graph = Solve::Graph.new
178
-
179
- graph.artifact("A", "1.0.0").depends("B", "~> 1.0.0")
180
- graph.artifact("A", "1.0.1").depends("B", "~> 1.0.0")
181
- graph.artifact("A", "1.0.2").depends("B", "~> 1.0.0")
182
-
183
- graph.artifact("B", "1.0.0").depends("C", "~> 1.0.0")
184
- graph.artifact("B", "1.0.1").depends("C", "~> 1.0.0")
185
- graph.artifact("B", "1.0.2").depends("C", "~> 1.0.0")
186
-
187
- graph.artifact("C", "1.0.0").depends("D", "1.0.0")
188
- graph.artifact("C", "1.0.1").depends("D", "1.0.0")
189
- graph.artifact("C", "1.0.2").depends("D", "1.0.0")
190
-
191
- # ensure we can't find a solution in the above
192
- graph.artifact("D", "1.0.0").depends("A", "< 0.0.0")
193
-
194
- # Add a solution to the graph that should be reached only after
195
- # all of the others have been tried
196
- # it must be circular to ensure that no other branch can find it
197
- graph.artifact("A", "0.0.0").depends("B", "0.0.0")
198
- graph.artifact("B", "0.0.0").depends("C", "0.0.0")
199
- graph.artifact("C", "0.0.0").depends("D", "0.0.0")
200
- graph.artifact("D", "0.0.0").depends("A", "0.0.0")
201
-
202
- demands = [["A"]]
203
-
204
- result = Solve.it!(graph, demands)
205
-
206
- result.should eql({ "A" => "0.0.0",
207
- "B" => "0.0.0",
208
- "C" => "0.0.0",
209
- "D" => "0.0.0"})
210
-
211
- end
212
-
213
- it "correctly resolves when a resolution exists but it is not the latest" do
214
- graph = Solve::Graph.new
215
-
216
- graph.artifact("get-the-old-one", "1.0.0")
217
- .depends("locked-mid-1", ">= 0.0.0")
218
- .depends("locked-mid-2", ">= 0.0.0")
219
- graph.artifact("get-the-old-one", "0.5.0")
220
-
221
- graph.artifact("locked-mid-1", "2.0.0").depends("old-bottom", "= 2.0.0")
222
- graph.artifact("locked-mid-1", "1.3.0").depends("old-bottom", "= 0.5.0")
223
- graph.artifact("locked-mid-1", "1.0.0")
224
-
225
- graph.artifact("locked-mid-2", "2.0.0").depends("old-bottom", "= 2.1.0")
226
- graph.artifact("locked-mid-2", "1.4.0").depends("old-bottom", "= 0.5.0")
227
- graph.artifact("locked-mid-2", "1.0.0")
228
-
229
- graph.artifact("old-bottom", "2.1.0")
230
- graph.artifact("old-bottom", "2.0.0")
231
- graph.artifact("old-bottom", "1.0.0")
232
- graph.artifact("old-bottom", "0.5.0")
233
-
234
- demands = [["get-the-old-one"]]
235
-
236
- result = Solve.it!(graph, demands)
237
-
238
- # ruby solver result:
239
- #
240
- # "get-the-old-one" => "1.0.0",
241
- # "locked-mid-1" => "2.0.0",
242
- # "locked-mid-2" => "1.0.0",
243
- # "old-bottom" => "2.0.0"
244
-
245
- result.should eql({
246
- "get-the-old-one" => "1.0.0",
247
- "locked-mid-1" => "1.0.0",
248
- "locked-mid-2" => "2.0.0",
249
- "old-bottom" => "2.1.0"
250
- })
251
- end
252
-
253
- describe "when options[:sorted] is true" do
254
- describe "with a simple list of dependencies" do
255
- it "returns a sorted list of dependencies" do
256
- graph = Solve::Graph.new
257
-
258
- graph.artifact("A", "1.0.0").depends("B", "= 1.0.0")
259
- graph.artifact("B", "1.0.0").depends("C", "= 1.0.0")
260
- graph.artifact("C", "1.0.0")
261
-
262
- demands = [["A"]]
263
-
264
- result = Solve.it!(graph, demands, { :sorted => true })
265
-
266
- result.should eql([
267
- ["C", "1.0.0"],
268
- ["B", "1.0.0"],
269
- ["A", "1.0.0"]
270
- ])
271
- end
272
- end
273
-
274
- # The order that the demands come in determines the order of artifacts
275
- # in the solver's variable_table. This must not determine the sort order
276
- describe "with a constraint that depends upon an earlier constrained artifact" do
277
- it "returns a sorted list of dependencies" do
278
- graph = Solve::Graph.new
279
-
280
- graph.artifact("B", "1.0.0").depends("A", "= 1.0.0")
281
- graph.artifact("A", "1.0.0").depends("C", "= 1.0.0")
282
- graph.artifact("C", "1.0.0")
283
-
284
- demands = [["A"],["B"]]
285
-
286
- result = Solve.it!(graph, demands, { :sorted => true } )
287
-
288
- result.should eql([
289
- ["C", "1.0.0"],
290
- ["A", "1.0.0"],
291
- ["B", "1.0.0"]
292
- ])
293
- end
294
- end
295
-
296
- describe "when the solution is cyclic" do
297
- it "raises a Solve::Errors::UnsortableSolutionError which contains the unsorted solution" do
298
- graph = Solve::Graph.new
299
-
300
- graph.artifact("A", "1.0.0").depends("B", "= 1.0.0")
301
- graph.artifact("B", "1.0.0").depends("C", "= 1.0.0")
302
- graph.artifact("C", "1.0.0").depends("A", "= 1.0.0")
303
-
304
- demands = [["A"]]
305
-
306
- expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
307
- error.should be_a(Solve::Errors::UnsortableSolutionError)
308
- error.unsorted_solution.should eql({
309
- "A" => "1.0.0",
310
- "B" => "1.0.0",
311
- "C" => "1.0.0",
312
- })
313
- }
314
- end
315
- end
316
- end
317
- end