generated from moul/golang-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Manfred Touron <[email protected]>
- Loading branch information
Showing
7 changed files
with
103 additions
and
0 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
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 |
---|---|---|
|
@@ -4,3 +4,6 @@ GOBINS ?= . | |
NPM_PACKAGES ?= . | ||
|
||
include rules.mk | ||
|
||
integration: install | ||
cd examples && make integration |
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,14 @@ | ||
integration: | ||
# test with testman | ||
testman test -run ^TestStable ./... | ||
@# FIXME: test unstable tests | ||
@# FIXME: test broken tests | ||
|
||
# test with default tools | ||
go install moul.io/retry | ||
go test -run ^TestStable -count=20 ./... >/dev/null # should always work | ||
retry -m=5 --interval=0 -- "(go test -run ^TestBroken -count=1 ./... >/dev/null)" && exit 1 || exit 0 # should always fail | ||
retry -m=50 --interval=0 -- "(go test -run ^TestUnstable -count 1 ./... >/dev/null)" # should work at least 1/50 | ||
go mod tidy | ||
|
||
@echo "SUCCESS." |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
package testpkg | ||
|
||
import ( | ||
"fmt" | ||
"math/rand" | ||
) | ||
|
||
func AlwaysSucceed() error { | ||
return nil | ||
} | ||
|
||
func AlwaysFailing() error { | ||
return fmt.Errorf("hope is the key to life") | ||
} | ||
|
||
func MaySucceed() error { | ||
if rand.Intn(3) != 0 { | ||
return fmt.Errorf("oops, no luck, try again") | ||
} | ||
return nil | ||
} |
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,33 @@ | ||
package testpkg | ||
|
||
import ( | ||
"fmt" | ||
"math/rand" | ||
"testing" | ||
|
||
"moul.io/srand" | ||
) | ||
|
||
func ExampleAlwaysSucceed() { | ||
fmt.Println(AlwaysSucceed()) | ||
// Output: <nil> | ||
} | ||
|
||
func TestStableAlwaysSucceed(t *testing.T) { | ||
if err := AlwaysSucceed(); err != nil { | ||
t.Errorf("expect no error, got %v", err) | ||
} | ||
} | ||
|
||
func TestUnstableMaySucceed(t *testing.T) { | ||
rand.Seed(srand.Fast()) | ||
if err := MaySucceed(); err != nil { | ||
t.Errorf("expect no error, got %v", err) | ||
} | ||
} | ||
|
||
func TestBrokenAlwaysFailing(t *testing.T) { | ||
if err := AlwaysFailing(); err != nil { | ||
t.Errorf("expect no error, got %v", err) | ||
} | ||
} |