@@ -64,25 +64,32 @@ func TestSimplePlan(t *testing.T) {
6464 ExpectPlan * MergePlan
6565 ExpectErr error
6666 }{
67- {"nil segments" ,
68- nil , nil , nil , nil },
69- {"empty segments" ,
70- []Segment {}, nil , nil , nil },
71- {"1 segment" ,
67+ {
68+ "nil segments" ,
69+ nil , nil , nil , nil ,
70+ },
71+ {
72+ "empty segments" ,
73+ []Segment {},
74+ nil , nil , nil ,
75+ },
76+ {
77+ "1 segment" ,
7278 []Segment {segs [1 ]},
7379 nil ,
7480 nil ,
7581 nil ,
7682 },
77- {"2 segments" ,
83+ {
84+ "2 segments" ,
7885 []Segment {
7986 segs [1 ],
8087 segs [2 ],
8188 },
8289 nil ,
8390 & MergePlan {
8491 Tasks : []* MergeTask {
85- & MergeTask {
92+ {
8693 Segments : []Segment {
8794 segs [2 ],
8895 segs [1 ],
@@ -92,7 +99,8 @@ func TestSimplePlan(t *testing.T) {
9299 },
93100 nil ,
94101 },
95- {"3 segments" ,
102+ {
103+ "3 segments" ,
96104 []Segment {
97105 segs [1 ],
98106 segs [2 ],
@@ -101,7 +109,7 @@ func TestSimplePlan(t *testing.T) {
101109 nil ,
102110 & MergePlan {
103111 Tasks : []* MergeTask {
104- & MergeTask {
112+ {
105113 Segments : []Segment {
106114 segs [9 ],
107115 segs [2 ],
@@ -112,7 +120,8 @@ func TestSimplePlan(t *testing.T) {
112120 },
113121 nil ,
114122 },
115- {"many segments" ,
123+ {
124+ "many segments" ,
116125 []Segment {
117126 segs [1 ],
118127 segs [2 ],
@@ -130,7 +139,7 @@ func TestSimplePlan(t *testing.T) {
130139 },
131140 & MergePlan {
132141 Tasks : []* MergeTask {
133- & MergeTask {
142+ {
134143 Segments : []Segment {
135144 segs [6 ],
136145 segs [5 ],
@@ -144,14 +153,18 @@ func TestSimplePlan(t *testing.T) {
144153
145154 for testi , test := range tests {
146155 plan , err := Plan (test .Segments , test .Options )
156+
147157 if err != test .ExpectErr {
148158 testj , _ := json .Marshal (& test )
149- t . Errorf ( "testi: %d, test: %s, got err: %v" ,
150- testi , testj , err )
159+
160+ t . Errorf ( "testi: %d, test: %s, got err: %v" , testi , testj , err )
151161 }
162+
152163 if ! reflect .DeepEqual (plan , test .ExpectPlan ) {
153164 testj , _ := json .Marshal (& test )
165+
154166 planj , _ := json .Marshal (& plan )
167+
155168 t .Errorf ("testi: %d, test: %s, got plan: %s" ,
156169 testi , testj , planj )
157170 }
@@ -184,7 +197,8 @@ func TestCalcBudget(t *testing.T) {
184197 {0 , 0 , MergePlanOptions {}, 0 },
185198 {1 , 0 , MergePlanOptions {}, 1 },
186199 {9 , 0 , MergePlanOptions {}, 9 },
187- {1 , 1 ,
200+ {
201+ 1 , 1 ,
188202 MergePlanOptions {
189203 MaxSegmentsPerTier : 1 ,
190204 MaxSegmentSize : 1000 ,
@@ -194,7 +208,8 @@ func TestCalcBudget(t *testing.T) {
194208 },
195209 1 ,
196210 },
197- {21 , 1 ,
211+ {
212+ 21 , 1 ,
198213 MergePlanOptions {
199214 MaxSegmentsPerTier : 1 ,
200215 MaxSegmentSize : 1000 ,
@@ -204,7 +219,8 @@ func TestCalcBudget(t *testing.T) {
204219 },
205220 5 ,
206221 },
207- {21 , 1 ,
222+ {
223+ 21 , 1 ,
208224 MergePlanOptions {
209225 MaxSegmentsPerTier : 2 ,
210226 MaxSegmentSize : 1000 ,
@@ -214,18 +230,30 @@ func TestCalcBudget(t *testing.T) {
214230 },
215231 7 ,
216232 },
217- {1000 , 2000 , DefaultMergePlanOptions ,
218- 1 },
219- {5000 , 2000 , DefaultMergePlanOptions ,
220- 3 },
221- {10000 , 2000 , DefaultMergePlanOptions ,
222- 5 },
223- {30000 , 2000 , DefaultMergePlanOptions ,
224- 11 },
225- {1000000 , 2000 , DefaultMergePlanOptions ,
226- 24 },
227- {1000000000 , 2000 , DefaultMergePlanOptions ,
228- 54 },
233+ {
234+ 1000 , 2000 , DefaultMergePlanOptions ,
235+ 1 ,
236+ },
237+ {
238+ 5000 , 2000 , DefaultMergePlanOptions ,
239+ 3 ,
240+ },
241+ {
242+ 10000 , 2000 , DefaultMergePlanOptions ,
243+ 5 ,
244+ },
245+ {
246+ 30000 , 2000 , DefaultMergePlanOptions ,
247+ 11 ,
248+ },
249+ {
250+ 1000000 , 2000 , DefaultMergePlanOptions ,
251+ 24 ,
252+ },
253+ {
254+ 1000000000 , 2000 , DefaultMergePlanOptions ,
255+ 54 ,
256+ },
229257 }
230258
231259 for testi , test := range tests {
@@ -492,15 +520,13 @@ func TestPlanMaxSegmentSizeLimit(t *testing.T) {
492520 var totalLiveSize int64
493521 for _ , segs := range task .Segments {
494522 totalLiveSize += segs .LiveSize ()
495-
496523 }
497524 if totalLiveSize >= o .MaxSegmentSize {
498525 t .Errorf ("merged segments size: %d exceeding the MaxSegmentSize" +
499526 "limit: %d" , totalLiveSize , o .MaxSegmentSize )
500527 }
501528 }
502529 }
503-
504530}
505531
506532// ----------------------------------------
0 commit comments