This repository has been archived by the owner on Oct 30, 2019. It is now read-only.
forked from golang/dep
-
Notifications
You must be signed in to change notification settings - Fork 8
/
manifest_test.go
821 lines (777 loc) · 19.4 KB
/
manifest_test.go
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dep
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"log"
"reflect"
"strings"
"testing"
"github.com/golang/dep/gps"
"github.com/golang/dep/internal/test"
)
func TestReadManifest(t *testing.T) {
h := test.NewHelper(t)
defer h.Cleanup()
mf := h.GetTestFile("manifest/golden.toml")
defer mf.Close()
got, _, err := readManifest(mf)
if err != nil {
t.Fatalf("should have read manifest correctly, but got err %q", err)
}
c, _ := gps.NewSemverConstraint("^0.12.0")
want := Manifest{
Constraints: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang/dep"): {
Constraint: c,
},
gps.ProjectRoot("github.com/babble/brook"): {
Constraint: gps.Revision("d05d5aca9f895d19e9265839bffeadd74a2d2ecb"),
},
},
Ovr: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang/dep"): {
Source: "https://github.com/golang/dep",
Constraint: gps.NewBranch("master"),
},
},
Ignored: []string{"github.com/foo/bar"},
PruneOptions: gps.CascadingPruneOptions{
DefaultOptions: gps.PruneNestedVendorDirs | gps.PruneNonGoFiles,
PerProjectOptions: make(map[gps.ProjectRoot]gps.PruneOptionSet),
},
}
if !reflect.DeepEqual(got.Constraints, want.Constraints) {
t.Error("Valid manifest's dependencies did not parse as expected")
}
if !reflect.DeepEqual(got.Ovr, want.Ovr) {
t.Error("Valid manifest's overrides did not parse as expected")
}
if !reflect.DeepEqual(got.Ignored, want.Ignored) {
t.Error("Valid manifest's ignored did not parse as expected")
}
if !reflect.DeepEqual(got.PruneOptions, want.PruneOptions) {
t.Error("Valid manifest's prune options did not parse as expected")
t.Error(got.PruneOptions, want.PruneOptions)
}
}
func TestWriteManifest(t *testing.T) {
h := test.NewHelper(t)
defer h.Cleanup()
golden := "manifest/golden.toml"
want := h.GetTestFileString(golden)
c, _ := gps.NewSemverConstraint("^0.12.0")
m := NewManifest()
m.Constraints[gps.ProjectRoot("github.com/golang/dep")] = gps.ProjectProperties{
Constraint: c,
}
m.Constraints[gps.ProjectRoot("github.com/babble/brook")] = gps.ProjectProperties{
Constraint: gps.Revision("d05d5aca9f895d19e9265839bffeadd74a2d2ecb"),
}
m.Ovr[gps.ProjectRoot("github.com/golang/dep")] = gps.ProjectProperties{
Source: "https://github.com/golang/dep",
Constraint: gps.NewBranch("master"),
}
m.Ignored = []string{"github.com/foo/bar"}
m.PruneOptions = gps.CascadingPruneOptions{
DefaultOptions: gps.PruneNestedVendorDirs | gps.PruneNonGoFiles,
PerProjectOptions: make(map[gps.ProjectRoot]gps.PruneOptionSet),
}
got, err := m.MarshalTOML()
if err != nil {
t.Fatalf("error while marshaling valid manifest to TOML: %q", err)
}
if string(got) != want {
if *test.UpdateGolden {
if err = h.WriteTestFile(golden, string(got)); err != nil {
t.Fatal(err)
}
} else {
t.Errorf("valid manifest did not marshal to TOML as expected:\n(GOT):\n%s\n(WNT):\n%s", string(got), want)
}
}
}
func TestReadManifestErrors(t *testing.T) {
h := test.NewHelper(t)
defer h.Cleanup()
var err error
tests := []struct {
name string
file string
}{
{"multiple constraints", "manifest/error1.toml"},
{"multiple dependencies", "manifest/error2.toml"},
{"multiple overrides", "manifest/error3.toml"},
}
for _, tst := range tests {
mf := h.GetTestFile(tst.file)
defer mf.Close()
_, _, err = readManifest(mf)
if err == nil {
t.Errorf("reading manifest with %s should have caused error, but did not", tst.name)
} else if !strings.Contains(err.Error(), tst.name) {
t.Errorf("unexpected error %q; expected %s error", err, tst.name)
}
}
}
func TestValidateManifest(t *testing.T) {
cases := []struct {
name string
tomlString string
wantWarn []error
wantError error
}{
{
name: "valid required",
tomlString: `
required = ["github.com/foo/bar"]
`,
wantWarn: []error{},
wantError: nil,
},
{
name: "invalid required",
tomlString: `
required = "github.com/foo/bar"
`,
wantWarn: []error{},
wantError: errInvalidRequired,
},
{
name: "empty required",
tomlString: `
required = []
`,
wantWarn: []error{},
wantError: nil,
},
{
name: "invalid required list",
tomlString: `
required = [1, 2, 3]
`,
wantWarn: []error{},
wantError: errInvalidRequired,
},
{
name: "invalid required format",
tomlString: `
[[required]]
name = "foo"
`,
wantWarn: []error{},
wantError: errInvalidRequired,
},
{
name: "valid ignored",
tomlString: `
ignored = ["foo"]
`,
wantWarn: []error{},
wantError: nil,
},
{
name: "invalid ignored",
tomlString: `
ignored = "foo"
`,
wantWarn: []error{},
wantError: errInvalidIgnored,
},
{
name: "empty ignored",
tomlString: `
ignored = []
`,
wantWarn: []error{},
wantError: nil,
},
{
name: "invalid ignored list",
tomlString: `
ignored = [1, 2, 3]
`,
wantWarn: []error{},
wantError: errInvalidIgnored,
},
{
name: "invalid ignored format",
tomlString: `
[[ignored]]
name = "foo"
`,
wantWarn: []error{},
wantError: errInvalidIgnored,
},
{
name: "valid metadata",
tomlString: `
[metadata]
authors = "foo"
version = "1.0.0"
`,
wantWarn: []error{},
wantError: nil,
},
{
name: "invalid metadata",
tomlString: `
foo = "some-value"
version = 14
[[bar]]
author = "xyz"
[[constraint]]
name = "github.com/foo/bar"
version = ""
`,
wantWarn: []error{
errors.New("unknown field in manifest: foo"),
errors.New("unknown field in manifest: bar"),
errors.New("unknown field in manifest: version"),
},
wantError: nil,
},
{
name: "invalid metadata format",
tomlString: `
metadata = "project-name"
[[constraint]]
name = "github.com/foo/bar"
`,
wantWarn: []error{
errInvalidMetadata,
errors.New("branch, version, revision, or source should be provided for \"github.com/foo/bar\""),
},
wantError: nil,
},
{
name: "plain constraint",
tomlString: `
[[constraint]]
name = "github.com/foo/bar"
`,
wantWarn: []error{
errors.New("branch, version, revision, or source should be provided for \"github.com/foo/bar\""),
},
wantError: nil,
},
{
name: "empty constraint",
tomlString: `
[[constraint]]
`,
wantWarn: []error{
errNoName,
},
wantError: nil,
},
{
name: "invalid constraint",
tomlString: `
constraint = "foo"
`,
wantWarn: []error{},
wantError: errInvalidConstraint,
},
{
name: "invalid constraint list",
tomlString: `
constraint = ["foo", "bar"]
`,
wantWarn: []error{},
wantError: errInvalidConstraint,
},
{
name: "valid override",
tomlString: `
[[override]]
name = "github.com/foo/bar"
`,
wantWarn: []error{},
wantError: nil,
},
{
name: "empty override",
tomlString: `
[[override]]
`,
wantWarn: []error{
errNoName,
},
wantError: nil,
},
{
name: "invalid override",
tomlString: `
override = "bar"
`,
wantWarn: []error{},
wantError: errInvalidOverride,
},
{
name: "invalid override list",
tomlString: `
override = ["foo", "bar"]
`,
wantWarn: []error{},
wantError: errInvalidOverride,
},
{
name: "invalid fields",
tomlString: `
[[constraint]]
name = "github.com/foo/bar"
location = "some-value"
link = "some-other-value"
metadata = "foo"
[[override]]
nick = "foo"
`,
wantWarn: []error{
errors.New("invalid key \"location\" in \"constraint\""),
errors.New("invalid key \"link\" in \"constraint\""),
errors.New("metadata in \"constraint\" should be a TOML table"),
errors.New("branch, version, revision, or source should be provided for \"github.com/foo/bar\""),
errors.New("invalid key \"nick\" in \"override\""),
errNoName,
},
wantError: nil,
},
{
name: "constraint metadata",
tomlString: `
[[constraint]]
name = "github.com/foo/bar"
[constraint.metadata]
color = "blue"
`,
wantWarn: []error{
errors.New("branch, version, revision, or source should be provided for \"github.com/foo/bar\""),
},
wantError: nil,
},
{
name: "invalid revision",
tomlString: `
[[constraint]]
name = "github.com/foo/bar"
revision = "b86ad16"
`,
wantWarn: []error{
errors.New("revision \"b86ad16\" should not be in abbreviated form"),
},
wantError: nil,
},
{
name: "invalid hg revision",
tomlString: `
[[constraint]]
name = "foobar.com/hg"
revision = "8d43f8c0b836"
`,
wantWarn: []error{errors.New("revision \"8d43f8c0b836\" should not be in abbreviated form")},
wantError: nil,
},
{
name: "valid prune options",
tomlString: `
[prune]
non-go = true
`,
wantWarn: []error{},
wantError: nil,
},
{
name: "invalid root prune options",
tomlString: `
[prune]
non-go = false
`,
wantWarn: []error{},
wantError: errInvalidRootPruneValue,
},
{
name: "root options should not contain a name",
tomlString: `
[prune]
go-tests = true
name = "github.com/golang/dep"
`,
wantWarn: []error{
errRootPruneContainsName,
},
wantError: nil,
},
{
name: "invalid prune project",
tomlString: `
[prune]
non-go = true
[prune.project]
name = "github.com/org/project"
non-go = true
`,
wantWarn: []error{},
wantError: errInvalidPruneProject,
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
errs, err := validateManifest(c.tomlString)
// compare validation errors
if err != c.wantError {
t.Fatalf("manifest errors are not as expected: \n\t(GOT) %v \n\t(WNT) %v", err, c.wantError)
}
// compare length of error slice
if len(errs) != len(c.wantWarn) {
t.Fatalf("number of manifest errors are not as expected: \n\t(GOT) %v errors(%v)\n\t(WNT) %v errors(%v).", len(errs), errs, len(c.wantWarn), c.wantWarn)
}
// check if the expected errors exist in actual errors slice
for _, er := range errs {
if !containsErr(c.wantWarn, er) {
t.Fatalf("manifest errors are not as expected: \n\t(MISSING) %v\n\t(FROM) %v", er, c.wantWarn)
}
}
})
}
}
func TestCheckRedundantPruneOptions(t *testing.T) {
cases := []struct {
name string
pruneOptions gps.CascadingPruneOptions
wantWarn []error
}{
{
name: "all redundant on true",
pruneOptions: gps.CascadingPruneOptions{
DefaultOptions: 15,
PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
"github.com/golang/dep": {
NestedVendor: pvtrue,
UnusedPackages: pvtrue,
NonGoFiles: pvtrue,
GoTests: pvtrue,
},
},
},
wantWarn: []error{
fmt.Errorf("redundant prune option %q set for %q", "unused-packages", "github.com/golang/dep"),
fmt.Errorf("redundant prune option %q set for %q", "non-go", "github.com/golang/dep"),
fmt.Errorf("redundant prune option %q set for %q", "go-tests", "github.com/golang/dep"),
},
},
{
name: "all redundant on false",
pruneOptions: gps.CascadingPruneOptions{
DefaultOptions: 1,
PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
"github.com/golang/dep": {
NestedVendor: pvtrue,
UnusedPackages: pvfalse,
NonGoFiles: pvfalse,
GoTests: pvfalse,
},
},
},
wantWarn: []error{
fmt.Errorf("redundant prune option %q set for %q", "unused-packages", "github.com/golang/dep"),
fmt.Errorf("redundant prune option %q set for %q", "non-go", "github.com/golang/dep"),
fmt.Errorf("redundant prune option %q set for %q", "go-tests", "github.com/golang/dep"),
},
},
{
name: "redundancy mix across multiple projects",
pruneOptions: gps.CascadingPruneOptions{
DefaultOptions: 7,
PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
"github.com/golang/dep": {
NestedVendor: pvtrue,
NonGoFiles: pvtrue,
GoTests: pvtrue,
},
"github.com/other/project": {
NestedVendor: pvtrue,
UnusedPackages: pvfalse,
GoTests: pvfalse,
},
},
},
wantWarn: []error{
fmt.Errorf("redundant prune option %q set for %q", "non-go", "github.com/golang/dep"),
fmt.Errorf("redundant prune option %q set for %q", "go-tests", "github.com/other/project"),
},
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
errs := checkRedundantPruneOptions(c.pruneOptions)
// compare length of error slice
if len(errs) != len(c.wantWarn) {
t.Fatalf("number of manifest errors are not as expected:\n\t(GOT) %v errors(%v)\n\t(WNT) %v errors(%v).", len(errs), errs, len(c.wantWarn), c.wantWarn)
}
for _, er := range errs {
if !containsErr(c.wantWarn, er) {
t.Fatalf("manifest errors are not as expected:\n\t(MISSING)\n%v\n\t(FROM)\n%v", er, c.wantWarn)
}
}
})
}
}
func TestValidateProjectRoots(t *testing.T) {
cases := []struct {
name string
manifest Manifest
wantError error
wantWarn []string
}{
{
name: "empty Manifest",
manifest: Manifest{},
wantError: nil,
wantWarn: []string{},
},
{
name: "valid project root",
manifest: Manifest{
Constraints: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang/dep"): {
Constraint: gps.Any(),
},
},
},
wantError: nil,
wantWarn: []string{},
},
{
name: "invalid project roots in Constraints and Overrides",
manifest: Manifest{
Constraints: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang/dep/foo"): {
Constraint: gps.Any(),
},
gps.ProjectRoot("github.com/golang/go/xyz"): {
Constraint: gps.Any(),
},
gps.ProjectRoot("github.com/golang/fmt"): {
Constraint: gps.Any(),
},
},
Ovr: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang/mock/bar"): {
Constraint: gps.Any(),
},
gps.ProjectRoot("github.com/golang/mock"): {
Constraint: gps.Any(),
},
},
},
wantError: errInvalidProjectRoot,
wantWarn: []string{
"the name for \"github.com/golang/dep/foo\" should be changed to \"github.com/golang/dep\"",
"the name for \"github.com/golang/mock/bar\" should be changed to \"github.com/golang/mock\"",
"the name for \"github.com/golang/go/xyz\" should be changed to \"github.com/golang/go\"",
},
},
{
name: "invalid source path",
manifest: Manifest{
Constraints: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang"): {
Constraint: gps.Any(),
},
},
},
wantError: errInvalidProjectRoot,
wantWarn: []string{},
},
}
h := test.NewHelper(t)
defer h.Cleanup()
h.TempDir("src")
pwd := h.Path(".")
// Capture the stderr to verify the warnings
stderrOutput := &bytes.Buffer{}
errLogger := log.New(stderrOutput, "", 0)
ctx := &Ctx{
GOPATH: pwd,
Out: log.New(ioutil.Discard, "", 0),
Err: errLogger,
}
sm, err := ctx.SourceManager()
h.Must(err)
defer sm.Release()
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
// Empty the buffer for every case
stderrOutput.Reset()
err := ValidateProjectRoots(ctx, &c.manifest, sm)
if err != c.wantError {
t.Fatalf("unexpected error while validating project roots:\n\t(GOT): %v\n\t(WNT): %v", err, c.wantError)
}
warnings := stderrOutput.String()
for _, warn := range c.wantWarn {
if !strings.Contains(warnings, warn) {
t.Fatalf("expected ValidateProjectRoot errors to contain: %q", warn)
}
}
})
}
}
//func TestFromRawPruneOptions(t *testing.T) {
//cases := []struct {
//name string
//rawPruneOptions rawPruneOptions
//wantOptions gps.CascadingPruneOptions
//}{
//{
//name: "global all options project no options",
//rawPruneOptions: rawPruneOptions{
//UnusedPackages: true,
//NonGoFiles: true,
//GoTests: true,
//Projects: []map[string]interface{}{
//{
//"name": "github.com/golang/dep",
//pruneOptionUnusedPackages: false,
//pruneOptionNonGo: false,
//pruneOptionGoTests: false,
//},
//},
//},
//wantOptions: gps.CascadingPruneOptions{
//DefaultOptions: 15,
//PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
//"github.com/golang/dep": gps.PruneOptionSet{
//NestedVendor: pvtrue,
//UnusedPackages: pvfalse,
//NonGoFiles: pvfalse,
//GoTests: pvfalse,
//},
//},
//},
//},
//{
//name: "global all options project mixed options",
//rawPruneOptions: rawPruneOptions{
//UnusedPackages: true,
//NonGoFiles: true,
//GoTests: true,
//Projects: []map[string]interface{}{
//{
//"name": "github.com/golang/dep",
//pruneOptionUnusedPackages: false,
//},
//},
//},
//wantOptions: gps.CascadingPruneOptions{
//DefaultOptions: 15,
//PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
//"github.com/golang/dep": gps.PruneOptionSet{
//NestedVendor: pvtrue,
//UnusedPackages: pvfalse,
//},
//},
//},
//},
//{
//name: "global no options project all options",
//rawPruneOptions: rawPruneOptions{
//UnusedPackages: false,
//NonGoFiles: false,
//GoTests: false,
//Projects: []map[string]interface{}{
//{
//"name": "github.com/golang/dep",
//pruneOptionUnusedPackages: true,
//pruneOptionNonGo: true,
//pruneOptionGoTests: true,
//},
//},
//},
//wantOptions: gps.CascadingPruneOptions{
//DefaultOptions: 1,
//PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
//"github.com/golang/dep": gps.PruneOptionSet{
//NestedVendor: pvtrue,
//UnusedPackages: pvtrue,
//NonGoFiles: pvtrue,
//GoTests: pvtrue,
//},
//},
//},
//},
//}
//for _, c := range cases {
//t.Run(c.name, func(t *testing.T) {
//opts, err := fromRawPruneOptions(c.rawPruneOptions)
//if err != nil {
//t.Fatal(err)
//}
//if !reflect.DeepEqual(opts, c.wantOptions) {
//t.Fatalf("rawPruneOptions are not as expected:\n\t(GOT) %v\n\t(WNT) %v", opts, c.wantOptions)
//}
//})
//}
//}
func TestToRawPruneOptions(t *testing.T) {
cases := []struct {
name string
pruneOptions gps.CascadingPruneOptions
wantOptions rawPruneOptions
}{
{
name: "all options",
pruneOptions: gps.CascadingPruneOptions{DefaultOptions: 15},
wantOptions: rawPruneOptions{
UnusedPackages: true,
NonGoFiles: true,
GoTests: true,
},
},
{
name: "no options",
pruneOptions: gps.CascadingPruneOptions{DefaultOptions: 1},
wantOptions: rawPruneOptions{
UnusedPackages: false,
NonGoFiles: false,
GoTests: false,
},
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
raw := toRawPruneOptions(c.pruneOptions)
if !reflect.DeepEqual(raw, c.wantOptions) {
t.Fatalf("rawPruneOptions are not as expected:\n\t(GOT) %v\n\t(WNT) %v", raw, c.wantOptions)
}
})
}
}
func TestToRawPruneOptions_Panic(t *testing.T) {
pruneOptions := gps.CascadingPruneOptions{
DefaultOptions: 1,
PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
"github.com/carolynvs/deptest": {
NestedVendor: pvtrue,
},
},
}
defer func() {
if err := recover(); err == nil {
t.Error("toRawPruneOptions did not panic with non-empty ProjectOptions")
}
}()
_ = toRawPruneOptions(pruneOptions)
}
func containsErr(s []error, e error) bool {
for _, a := range s {
if a.Error() == e.Error() {
return true
}
}
return false
}