-
Notifications
You must be signed in to change notification settings - Fork 1k
Implement new spec for init #470
Changes from all commits
4a3101a
7268358
b444466
f467151
1e56bdd
0a0f777
8ab8cf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,11 @@ | |
|
||
package main | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
|
||
"github.com/sdboyer/gps" | ||
) | ||
|
||
func TestContains(t *testing.T) { | ||
a := []string{"a", "b", "abcd"} | ||
|
@@ -33,3 +37,46 @@ func TestIsStdLib(t *testing.T) { | |
} | ||
} | ||
} | ||
|
||
func TestGetProjectPropertiesFromVersion(t *testing.T) { | ||
cases := []struct { | ||
version gps.Version | ||
want gps.Version | ||
}{ | ||
{ | ||
version: gps.NewBranch("foo-branch"), | ||
want: gps.NewBranch("foo-branch"), | ||
}, | ||
{ | ||
version: gps.NewVersion("foo-version"), | ||
want: gps.NewVersion("foo-version"), | ||
}, | ||
{ | ||
version: gps.NewBranch("foo-branch").Is("some-revision"), | ||
want: gps.NewBranch("foo-branch"), | ||
}, | ||
{ | ||
version: gps.NewVersion("foo-version").Is("some-revision"), | ||
want: gps.NewVersion("foo-version"), | ||
}, | ||
{ | ||
version: gps.Revision("some-revision"), | ||
want: nil, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
actualProp := getProjectPropertiesFromVersion(c.version) | ||
if c.want != actualProp.Constraint { | ||
t.Fatalf("Expected project property to be %v, got %v", actualProp.Constraint, c.want) | ||
} | ||
} | ||
|
||
// Test to have caret in semver version | ||
outsemver := getProjectPropertiesFromVersion(gps.NewVersion("v1.0.0")) | ||
wantSemver, _ := gps.NewSemverConstraint("^1.0.0") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The actual problem here is an annoying implementation detail - it should work without needing to fall back on string comparison if you use |
||
|
||
if outsemver.Constraint.String() != wantSemver.String() { | ||
t.Fatalf("Expected semver to be %v, got %v", outsemver.Constraint, wantSemver) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptestdos" | ||
revision = "a0196baa11ea047dd65037287451d36b861b00ea" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptestdos" | ||
revision = "a0196baa11ea047dd65037287451d36b861b00ea" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptest" | ||
version = "^1.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to pick the constraints and add to manifests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not one that's wrapped up in a nice function, but there is something sorta analogous - I'll make more detailed comments down on the impl. But really, the algorithm you'll want to follow for this is bulleted in the spec doc. 😄