From 8e32b68aa020f1f5aa10555d0ae98166080f79ea Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Mon, 21 Jun 2021 16:21:44 +0200 Subject: [PATCH] reproduce #371 Signed-off-by: Pierre Fenoll --- .github/workflows/go.yml | 1 + openapi3/race_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 openapi3/race_test.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6233f67e8..499ab730b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -65,6 +65,7 @@ jobs: run: git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]] - run: go test ./... + - run: go test -v -run TestRaceyPatternSchema -race ./... - run: | cd openapi3/testdata go get -u -v github.com/getkin/kin-openapi diff --git a/openapi3/race_test.go b/openapi3/race_test.go new file mode 100644 index 000000000..8bd47c007 --- /dev/null +++ b/openapi3/race_test.go @@ -0,0 +1,26 @@ +package openapi3_test + +import ( + "context" + "testing" + + "github.com/getkin/kin-openapi/openapi3" + "github.com/stretchr/testify/require" +) + +func TestRaceyPatternSchema(t *testing.T) { + schema := openapi3.Schema{ + Pattern: "^test|for|race|condition$", + } + + err := schema.Validate(context.Background()) + require.NoError(t, err) + + visit := func() { + err := schema.VisitJSONString("test") + require.NoError(t, err) + } + + go visit() + visit() +}