@@ -8,17 +8,12 @@ import (
8
8
"bytes"
9
9
"flag"
10
10
"fmt"
11
- "io/ioutil"
12
11
"log"
13
- "math/rand"
14
12
"reflect"
15
13
"sort"
16
- "strconv"
17
14
"strings"
18
15
"testing"
19
16
"unicode"
20
-
21
- "github.com/golang/dep/internal/gps/pkgtree"
22
17
)
23
18
24
19
var fixtorun string
@@ -292,150 +287,3 @@ func TestRootLockNoVersionPairMatching(t *testing.T) {
292
287
293
288
fixtureSolveSimpleChecks (fix , res , err , t )
294
289
}
295
-
296
- // TestBadSolveOpts exercises the different possible inputs to a solver that can
297
- // be determined as invalid in Prepare(), without any further work
298
- func TestBadSolveOpts (t * testing.T ) {
299
- pn := strconv .FormatInt (rand .Int63 (), 36 )
300
- fix := basicFixtures ["no dependencies" ]
301
- fix .ds [0 ].n = ProjectRoot (pn )
302
-
303
- sm := newdepspecSM (fix .ds , nil )
304
- params := SolveParameters {
305
- mkBridgeFn : overrideMkBridge ,
306
- }
307
-
308
- _ , err := Prepare (params , nil )
309
- if err == nil {
310
- t .Errorf ("Prepare should have errored on nil SourceManager" )
311
- } else if ! strings .Contains (err .Error (), "non-nil SourceManager" ) {
312
- t .Error ("Prepare should have given error on nil SourceManager, but gave:" , err )
313
- }
314
-
315
- _ , err = Prepare (params , sm )
316
- if err == nil {
317
- t .Errorf ("Prepare should have errored without ProjectAnalyzer" )
318
- } else if ! strings .Contains (err .Error (), "must provide a ProjectAnalyzer" ) {
319
- t .Error ("Prepare should have given error without ProjectAnalyzer, but gave:" , err )
320
- }
321
-
322
- params .ProjectAnalyzer = naiveAnalyzer {}
323
- _ , err = Prepare (params , sm )
324
- if err == nil {
325
- t .Errorf ("Prepare should have errored on empty root" )
326
- } else if ! strings .Contains (err .Error (), "non-empty root directory" ) {
327
- t .Error ("Prepare should have given error on empty root, but gave:" , err )
328
- }
329
-
330
- params .RootDir = pn
331
- _ , err = Prepare (params , sm )
332
- if err == nil {
333
- t .Errorf ("Prepare should have errored on empty name" )
334
- } else if ! strings .Contains (err .Error (), "non-empty import root" ) {
335
- t .Error ("Prepare should have given error on empty import root, but gave:" , err )
336
- }
337
-
338
- params .RootPackageTree = pkgtree.PackageTree {
339
- ImportRoot : pn ,
340
- }
341
- _ , err = Prepare (params , sm )
342
- if err == nil {
343
- t .Errorf ("Prepare should have errored on empty name" )
344
- } else if ! strings .Contains (err .Error (), "at least one package" ) {
345
- t .Error ("Prepare should have given error on empty import root, but gave:" , err )
346
- }
347
-
348
- params .RootPackageTree = pkgtree.PackageTree {
349
- ImportRoot : pn ,
350
- Packages : map [string ]pkgtree.PackageOrErr {
351
- pn : {
352
- P : pkgtree.Package {
353
- ImportPath : pn ,
354
- Name : pn ,
355
- },
356
- },
357
- },
358
- }
359
- params .TraceLogger = log .New (ioutil .Discard , "" , 0 )
360
-
361
- params .Manifest = simpleRootManifest {
362
- ovr : ProjectConstraints {
363
- ProjectRoot ("foo" ): ProjectProperties {},
364
- },
365
- }
366
- _ , err = Prepare (params , sm )
367
- if err == nil {
368
- t .Errorf ("Should have errored on override with empty ProjectProperties" )
369
- } else if ! strings .Contains (err .Error (), "foo, but without any non-zero properties" ) {
370
- t .Error ("Prepare should have given error override with empty ProjectProperties, but gave:" , err )
371
- }
372
-
373
- params .Manifest = simpleRootManifest {
374
- ig : map [string ]bool {"foo" : true },
375
- req : map [string ]bool {"foo" : true },
376
- }
377
- _ , err = Prepare (params , sm )
378
- if err == nil {
379
- t .Errorf ("Should have errored on pkg both ignored and required" )
380
- } else if ! strings .Contains (err .Error (), "was given as both a required and ignored package" ) {
381
- t .Error ("Prepare should have given error with single ignore/require conflict error, but gave:" , err )
382
- }
383
-
384
- params .Manifest = simpleRootManifest {
385
- ig : map [string ]bool {"foo" : true , "bar" : true },
386
- req : map [string ]bool {"foo" : true , "bar" : true },
387
- }
388
- _ , err = Prepare (params , sm )
389
- if err == nil {
390
- t .Errorf ("Should have errored on pkg both ignored and required" )
391
- } else if ! strings .Contains (err .Error (), "multiple packages given as both required and ignored:" ) {
392
- t .Error ("Prepare should have given error with multiple ignore/require conflict error, but gave:" , err )
393
- }
394
- params .Manifest = nil
395
-
396
- params .ToChange = []ProjectRoot {"foo" }
397
- _ , err = Prepare (params , sm )
398
- if err == nil {
399
- t .Errorf ("Should have errored on non-empty ToChange without a lock provided" )
400
- } else if ! strings .Contains (err .Error (), "update specifically requested for" ) {
401
- t .Error ("Prepare should have given error on ToChange without Lock, but gave:" , err )
402
- }
403
-
404
- params .Lock = safeLock {
405
- p : []LockedProject {
406
- NewLockedProject (mkPI ("bar" ), Revision ("makebelieve" ), nil ),
407
- },
408
- }
409
- _ , err = Prepare (params , sm )
410
- if err == nil {
411
- t .Errorf ("Should have errored on ToChange containing project not in lock" )
412
- } else if ! strings .Contains (err .Error (), "cannot update foo as it is not in the lock" ) {
413
- t .Error ("Prepare should have given error on ToChange with item not present in Lock, but gave:" , err )
414
- }
415
-
416
- params .Lock , params .ToChange = nil , nil
417
- _ , err = Prepare (params , sm )
418
- if err != nil {
419
- t .Error ("Basic conditions satisfied, prepare should have completed successfully, err as:" , err )
420
- }
421
-
422
- // swap out the test mkBridge override temporarily, just to make sure we get
423
- // the right error
424
- params .mkBridgeFn = nil
425
-
426
- _ , err = Prepare (params , sm )
427
- if err == nil {
428
- t .Errorf ("Should have errored on nonexistent root" )
429
- } else if ! strings .Contains (err .Error (), "could not read project root" ) {
430
- t .Error ("Prepare should have given error nonexistent project root dir, but gave:" , err )
431
- }
432
-
433
- // Pointing it at a file should also be an err
434
- params .RootDir = "solve_test.go"
435
- _ , err = Prepare (params , sm )
436
- if err == nil {
437
- t .Errorf ("Should have errored on file for RootDir" )
438
- } else if ! strings .Contains (err .Error (), "is a file, not a directory" ) {
439
- t .Error ("Prepare should have given error on file as RootDir, but gave:" , err )
440
- }
441
- }
0 commit comments