Skip to content

Commit

Permalink
Automatically generate assertions.go
Browse files Browse the repository at this point in the history
Adds a scrappy script to update assertions.go directly from the
assertions library's own exported Should* symbols.
  • Loading branch information
riannucci committed Oct 28, 2021
1 parent 6119263 commit 9859b3e
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 61 deletions.
124 changes: 63 additions & 61 deletions convey/assertions.go
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
)
31 changes: 31 additions & 0 deletions convey/update_assertions.sh
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

0 comments on commit 9859b3e

Please sign in to comment.