Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit f850240

Browse files
authored
Merge pull request #620 from jmank88/test_cleanup
gps tests: dry and cleanup; remove unused code
2 parents 4088a1b + 775c77c commit f850240

File tree

3 files changed

+13
-34
lines changed

3 files changed

+13
-34
lines changed

internal/gps/deduce_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -587,21 +587,16 @@ func TestDeduceFromPath(t *testing.T) {
587587
}
588588
})
589589
}
590-
for typ, fixtures := range pathDeductionFixtures {
591-
typ, fixtures := typ, fixtures
592-
t.Run("first", func(t *testing.T) {
590+
runSet := func(t *testing.T) {
591+
for typ, fixtures := range pathDeductionFixtures {
593592
do(typ, fixtures, t)
594-
})
593+
}
595594
}
595+
t.Run("first", runSet)
596596

597597
// Run the test set twice to ensure results are correct for both cached
598598
// and uncached deductions.
599-
for typ, fixtures := range pathDeductionFixtures {
600-
typ, fixtures := typ, fixtures
601-
t.Run("second", func(t *testing.T) {
602-
do(typ, fixtures, t)
603-
})
604-
}
599+
t.Run("second", runSet)
605600
}
606601

607602
func TestVanityDeduction(t *testing.T) {

internal/gps/manager_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ import (
1616
"sync/atomic"
1717
"testing"
1818
"time"
19-
20-
"github.com/Masterminds/semver"
2119
)
2220

23-
var bd string
24-
2521
// An analyzer that passes nothing back, but doesn't error. This is the naive
2622
// case - no constraints, no lock, and no errors. The SourceManager will
2723
// interpret this as open/Any constraints on everything in the import graph.
@@ -35,15 +31,6 @@ func (a naiveAnalyzer) Info() (name string, version int) {
3531
return "naive-analyzer", 1
3632
}
3733

38-
func sv(s string) semver.Version {
39-
sv, err := semver.NewVersion(s)
40-
if err != nil {
41-
panic(fmt.Sprintf("Error creating semver from %q: %s", s, err))
42-
}
43-
44-
return sv
45-
}
46-
4734
func mkNaiveSM(t *testing.T) (*SourceMgr, func()) {
4835
cpath, err := ioutil.TempDir("", "smcache")
4936
if err != nil {
@@ -82,11 +69,6 @@ func remakeNaiveSM(osm *SourceMgr, t *testing.T) (*SourceMgr, func()) {
8269
}
8370
}
8471

85-
func init() {
86-
_, filename, _, _ := runtime.Caller(1)
87-
bd = path.Dir(filename)
88-
}
89-
9072
func TestSourceManagerInit(t *testing.T) {
9173
cpath, err := ioutil.TempDir("", "smcache")
9274
if err != nil {

internal/gps/result_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
)
1414

1515
var basicResult solution
16-
var kub atom
1716

1817
func pi(n string) ProjectIdentifier {
1918
return ProjectIdentifier{
@@ -36,11 +35,14 @@ func init() {
3635
},
3736
}
3837

39-
// just in case something needs punishing, kubernetes is happy to oblige
40-
kub = atom{
41-
id: pi("github.com/kubernetes/kubernetes"),
42-
v: NewVersion("1.0.0").Is(Revision("528f879e7d3790ea4287687ef0ab3f2a01cc2718")),
43-
}
38+
// Just in case something needs punishing, kubernetes offers a complex,
39+
// real-world set of dependencies, and this revision is known to work.
40+
/*
41+
_ = atom{
42+
id: pi("github.com/kubernetes/kubernetes"),
43+
v: NewVersion("1.0.0").Is(Revision("528f879e7d3790ea4287687ef0ab3f2a01cc2718")),
44+
}
45+
*/
4446
}
4547

4648
func testWriteDepTree(t *testing.T) {

0 commit comments

Comments
 (0)