From 7afd6582001bf4e1803658c680923e0f9ab34040 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Sat, 13 Aug 2022 17:06:54 +0700 Subject: [PATCH] chore: add example --- Makefile | 9 +++++---- example/example_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 example/example_test.go diff --git a/Makefile b/Makefile index a23b6bd..d6efa92 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ .PHONY: all test-color lint try-4-real -all: test-color lint try-4-real +all: test-color lint + go mod tidy test-color: go install github.com/haunt98/go-test-color@latest - go-test-color -race -failfast ./... + go-test-color -race -failfast . lint: - golangci-lint run ./... + golangci-lint run . try-4-real: - go run . + go run . -race ./example/... diff --git a/example/example_test.go b/example/example_test.go new file mode 100644 index 0000000..a3156ab --- /dev/null +++ b/example/example_test.go @@ -0,0 +1,35 @@ +package example + +import ( + "testing" + "time" +) + +const longTime = time.Second * 2 + +func TestPassShortTime(t *testing.T) { +} + +func TestPassLongTime(t *testing.T) { + time.Sleep(longTime) +} + +func TestFailShorTime(t *testing.T) { + t.Fail() +} + +func TestFailLongTime(t *testing.T) { + time.Sleep(longTime) + t.Fail() +} + +func TestFailShorTimeParallel(t *testing.T) { + t.Parallel() + t.Fail() +} + +func TestFailLongTimeParallel(t *testing.T) { + t.Parallel() + time.Sleep(longTime) + t.Fail() +}