forked from smartystreets/goconvey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically generate assertions.go
Adds a scrappy script to update assertions.go directly from the assertions library's own exported Should* symbols.
- Loading branch information
Showing
2 changed files
with
94 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,75 @@ | ||
package convey | ||
|
||
// DO NOT EDIT: generated by update_assertions.sh | ||
|
||
//go:generate ./update_assertions.sh | ||
|
||
import "github.com/smartystreets/assertions" | ||
|
||
// These assertions are forwarded from github.com/smartystreets/assertions | ||
// in order to make convey self-contained. | ||
var ( | ||
ShouldEqual = assertions.ShouldEqual | ||
ShouldNotEqual = assertions.ShouldNotEqual | ||
ShouldAlmostEqual = assertions.ShouldAlmostEqual | ||
ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual | ||
ShouldEqualJSON = assertions.ShouldEqualJSON | ||
ShouldResemble = assertions.ShouldResemble | ||
ShouldNotResemble = assertions.ShouldNotResemble | ||
ShouldPointTo = assertions.ShouldPointTo | ||
ShouldNotPointTo = assertions.ShouldNotPointTo | ||
ShouldBeNil = assertions.ShouldBeNil | ||
ShouldNotBeNil = assertions.ShouldNotBeNil | ||
ShouldBeTrue = assertions.ShouldBeTrue | ||
ShouldBeFalse = assertions.ShouldBeFalse | ||
ShouldBeZeroValue = assertions.ShouldBeZeroValue | ||
ShouldNotBeZeroValue = assertions.ShouldNotBeZeroValue | ||
|
||
ShouldAlmostEqual = assertions.ShouldAlmostEqual | ||
ShouldBeBetween = assertions.ShouldBeBetween | ||
ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual | ||
ShouldBeBlank = assertions.ShouldBeBlank | ||
ShouldBeChronological = assertions.ShouldBeChronological | ||
ShouldBeEmpty = assertions.ShouldBeEmpty | ||
ShouldBeError = assertions.ShouldBeError | ||
ShouldBeFalse = assertions.ShouldBeFalse | ||
ShouldBeGreaterThan = assertions.ShouldBeGreaterThan | ||
ShouldBeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo | ||
ShouldBeIn = assertions.ShouldBeIn | ||
ShouldBeLessThan = assertions.ShouldBeLessThan | ||
ShouldBeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo | ||
ShouldBeBetween = assertions.ShouldBeBetween | ||
ShouldBeNil = assertions.ShouldBeNil | ||
ShouldBeTrue = assertions.ShouldBeTrue | ||
ShouldBeZeroValue = assertions.ShouldBeZeroValue | ||
ShouldContain = assertions.ShouldContain | ||
ShouldContainKey = assertions.ShouldContainKey | ||
ShouldContainSubstring = assertions.ShouldContainSubstring | ||
ShouldEndWith = assertions.ShouldEndWith | ||
ShouldEqual = assertions.ShouldEqual | ||
ShouldEqualJSON = assertions.ShouldEqualJSON | ||
ShouldEqualTrimSpace = assertions.ShouldEqualTrimSpace | ||
ShouldEqualWithout = assertions.ShouldEqualWithout | ||
ShouldHappenAfter = assertions.ShouldHappenAfter | ||
ShouldHappenBefore = assertions.ShouldHappenBefore | ||
ShouldHappenBetween = assertions.ShouldHappenBetween | ||
ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter | ||
ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore | ||
ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween | ||
ShouldHappenWithin = assertions.ShouldHappenWithin | ||
ShouldHaveLength = assertions.ShouldHaveLength | ||
ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs | ||
ShouldImplement = assertions.ShouldImplement | ||
ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual | ||
ShouldNotBeBetween = assertions.ShouldNotBeBetween | ||
ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual | ||
ShouldNotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual | ||
|
||
ShouldContain = assertions.ShouldContain | ||
ShouldNotContain = assertions.ShouldNotContain | ||
ShouldContainKey = assertions.ShouldContainKey | ||
ShouldNotContainKey = assertions.ShouldNotContainKey | ||
ShouldBeIn = assertions.ShouldBeIn | ||
ShouldNotBeIn = assertions.ShouldNotBeIn | ||
ShouldBeEmpty = assertions.ShouldBeEmpty | ||
ShouldNotBeEmpty = assertions.ShouldNotBeEmpty | ||
ShouldHaveLength = assertions.ShouldHaveLength | ||
|
||
ShouldStartWith = assertions.ShouldStartWith | ||
ShouldNotStartWith = assertions.ShouldNotStartWith | ||
ShouldEndWith = assertions.ShouldEndWith | ||
ShouldNotEndWith = assertions.ShouldNotEndWith | ||
ShouldBeBlank = assertions.ShouldBeBlank | ||
ShouldNotBeBlank = assertions.ShouldNotBeBlank | ||
ShouldContainSubstring = assertions.ShouldContainSubstring | ||
ShouldNotContainSubstring = assertions.ShouldNotContainSubstring | ||
|
||
ShouldPanic = assertions.ShouldPanic | ||
ShouldNotPanic = assertions.ShouldNotPanic | ||
ShouldPanicWith = assertions.ShouldPanicWith | ||
ShouldNotPanicWith = assertions.ShouldNotPanicWith | ||
|
||
ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs | ||
ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs | ||
ShouldImplement = assertions.ShouldImplement | ||
ShouldNotImplement = assertions.ShouldNotImplement | ||
|
||
ShouldHappenBefore = assertions.ShouldHappenBefore | ||
ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore | ||
ShouldHappenAfter = assertions.ShouldHappenAfter | ||
ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter | ||
ShouldHappenBetween = assertions.ShouldHappenBetween | ||
ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween | ||
ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween | ||
ShouldHappenWithin = assertions.ShouldHappenWithin | ||
ShouldNotHappenWithin = assertions.ShouldNotHappenWithin | ||
ShouldBeChronological = assertions.ShouldBeChronological | ||
|
||
ShouldBeError = assertions.ShouldBeError | ||
ShouldWrap = assertions.ShouldWrap | ||
ShouldNotBeBlank = assertions.ShouldNotBeBlank | ||
ShouldNotBeChronological = assertions.ShouldNotBeChronological | ||
ShouldNotBeEmpty = assertions.ShouldNotBeEmpty | ||
ShouldNotBeIn = assertions.ShouldNotBeIn | ||
ShouldNotBeNil = assertions.ShouldNotBeNil | ||
ShouldNotBeZeroValue = assertions.ShouldNotBeZeroValue | ||
ShouldNotContain = assertions.ShouldNotContain | ||
ShouldNotContainKey = assertions.ShouldNotContainKey | ||
ShouldNotContainSubstring = assertions.ShouldNotContainSubstring | ||
ShouldNotEndWith = assertions.ShouldNotEndWith | ||
ShouldNotEqual = assertions.ShouldNotEqual | ||
ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween | ||
ShouldNotHappenWithin = assertions.ShouldNotHappenWithin | ||
ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs | ||
ShouldNotImplement = assertions.ShouldNotImplement | ||
ShouldNotPanic = assertions.ShouldNotPanic | ||
ShouldNotPanicWith = assertions.ShouldNotPanicWith | ||
ShouldNotPointTo = assertions.ShouldNotPointTo | ||
ShouldNotResemble = assertions.ShouldNotResemble | ||
ShouldNotStartWith = assertions.ShouldNotStartWith | ||
ShouldPanic = assertions.ShouldPanic | ||
ShouldPanicWith = assertions.ShouldPanicWith | ||
ShouldPointTo = assertions.ShouldPointTo | ||
ShouldResemble = assertions.ShouldResemble | ||
ShouldStartWith = assertions.ShouldStartWith | ||
ShouldWrap = assertions.ShouldWrap | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd "$(dirname $(realpath $0))" | ||
|
||
ASSERTIONS=($( | ||
go tool nm "$(go list -export -f '{{.Export}}' github.com/smartystreets/assertions)" |\ | ||
awk '/ T github\.com\/smartystreets\/assertions\.Should/{split($3, a, "."); print a[3]}' |\ | ||
sort | uniq)) | ||
|
||
( | ||
echo "package convey" | ||
echo | ||
echo "// DO NOT EDIT: generated by update_assertions.sh" | ||
echo | ||
echo "//go:generate ./update_assertions.sh" | ||
echo | ||
echo "import \"github.com/smartystreets/assertions\"" | ||
echo | ||
echo "// These assertions are forwarded from github.com/smartystreets/assertions" | ||
echo "// in order to make convey self-contained." | ||
echo "var (" | ||
|
||
for assertion in "${ASSERTIONS[@]}" | ||
do | ||
echo " $assertion = assertions.$assertion" | ||
done | ||
|
||
echo ")" | ||
) > ./assertions.go | ||
|
||
go fmt ./assertions.go |