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

Commit 8f12cdb

Browse files
committed
fixup! Make the godep importer tests table based
1 parent 91449e6 commit 8f12cdb

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

cmd/dep/godep_importer_test.go

+9-13
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestGoDepConfig_Convert(t *testing.T) {
2828
expectedConstraint string
2929
expectedRevision *gps.Revision
3030
expectedVersion string
31-
expectedLockCount *int
31+
expectedLockCount int
3232
}{
3333
"convert project": {
3434
json: godepJSON{
@@ -46,6 +46,7 @@ func TestGoDepConfig_Convert(t *testing.T) {
4646
expectedConstraint: "^0.8.0",
4747
expectedRevision: gps.RevisionPtr(gps.Revision("ff2948a2ac8f538c4ecd55962e919d1e13e74baf")),
4848
expectedVersion: "v0.8.0",
49+
expectedLockCount: 1,
4950
},
5051
"with semver suffix": {
5152
json: godepJSON{
@@ -60,6 +61,7 @@ func TestGoDepConfig_Convert(t *testing.T) {
6061
projectRoot: gps.ProjectRoot("github.com/sdboyer/deptest"),
6162
matchPairedVersion: false,
6263
expectedConstraint: ">=1.12.0, <=12.0.0-g2fd980e",
64+
expectedLockCount: 1,
6365
},
6466
"empty comment": {
6567
json: godepJSON{
@@ -76,6 +78,7 @@ func TestGoDepConfig_Convert(t *testing.T) {
7678
expectedConstraint: "^1.0.0",
7779
expectedRevision: gps.RevisionPtr(gps.Revision("ff2948a2ac8f538c4ecd55962e919d1e13e74baf")),
7880
expectedVersion: "v1.0.0",
81+
expectedLockCount: 1,
7982
},
8083
"bad input - empty package name": {
8184
json: godepJSON{
@@ -110,7 +113,7 @@ func TestGoDepConfig_Convert(t *testing.T) {
110113
},
111114
projectRoot: gps.ProjectRoot("github.com/sdboyer/deptest"),
112115
notExpectedProjectRoot: gps.ProjectRootPtr(gps.ProjectRoot("github.com/sdboyer/deptest/foo")),
113-
expectedLockCount: intPtr(1),
116+
expectedLockCount: 1,
114117
expectedConstraint: "^1.0.0",
115118
expectedVersion: "v1.0.0",
116119
},
@@ -139,12 +142,10 @@ func TestGoDepConfig_Convert(t *testing.T) {
139142
t.Fatal(err)
140143
}
141144

142-
if testCase.expectedLockCount != nil {
143-
if len(lock.P) != *testCase.expectedLockCount {
144-
t.Fatalf("Expected lock to have %d project(s), got %d",
145-
*testCase.expectedLockCount,
146-
len(lock.P))
147-
}
145+
if len(lock.P) != testCase.expectedLockCount {
146+
t.Fatalf("Expected lock to have %d project(s), got %d",
147+
testCase.expectedLockCount,
148+
len(lock.P))
148149
}
149150

150151
d, ok := manifest.Constraints[testCase.projectRoot]
@@ -337,8 +338,3 @@ func equalImports(a, b []godepPackage) bool {
337338

338339
return true
339340
}
340-
341-
// intPtr takes a int value and returns a pointer.
342-
func intPtr(i int) *int {
343-
return &i
344-
}

0 commit comments

Comments
 (0)