diff --git a/.github/workflows/intergration-test.yml b/.github/workflows/intergration-test.yml index 41ddb54..f11483f 100644 --- a/.github/workflows/intergration-test.yml +++ b/.github/workflows/intergration-test.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - go: [ "1.14", "1.15" ] + go: [ "1.15", "1.16" ] steps: - name: Set up Go 1.x @@ -22,6 +22,7 @@ jobs: - name: Test env: + STORAGE_OSS_INTEGRATION_TEST: ${{ secrets.STORAGE_INTEGRATION_TEST }} STORAGE_OSS_CREDENTIAL: ${{ secrets.STORAGE_OSS_CREDENTIAL }} STORAGE_OSS_NAME: ${{ secrets.STORAGE_OSS_NAME }} STORAGE_OSS_ENDPOINT: ${{ secrets.STORAGE_OSS_ENDPOINT }} diff --git a/Makefile b/Makefile index d975246..f14abf4 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ generate: go generate ./... go fmt ./... -build: generate tidy check +build: tidy generate check go build ./... test: @@ -32,8 +32,7 @@ test: go tool cover -html="coverage.txt" -o "coverage.html" integration_test: - go clean -testcache ./tests - go test -tags integration_test -race -covermode=atomic -v ./tests + go test -count=1 -race -covermode=atomic -v ./tests tidy: go mod tidy diff --git a/Makefile.env.example b/Makefile.env.example index d4a631e..d27336a 100644 --- a/Makefile.env.example +++ b/Makefile.env.example @@ -1,3 +1,4 @@ +export STORAGE_OSS_INTEGRATION_TEST=on export STORAGE_OSS_CREDENTIAL=hmac:access_key:secret_key export STORAGE_OSS_NAME=bucketname export STORAGE_OSS_ENDPOINT=https:oss-region-name.aliyuncs.com \ No newline at end of file diff --git a/go.sum b/go.sum index 0d13e15..ff32f80 100644 --- a/go.sum +++ b/go.sum @@ -46,6 +46,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= @@ -60,6 +61,7 @@ golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgm golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -85,6 +87,7 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/src-d/go-billy.v4 v4.3.0 h1:KtlZ4c1OWbIs4jCv5ZXrTqG8EQocr0g/d4DjNg70aek= gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..48fd8b8 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,32 @@ +## How run integration tests + +### Run tests locally + +Copy example files and update corresponding values. + +```shell +cp Makefile.env.exmaple Makefile.env +``` + +Run tests + +```shell +make integration_test +``` + +### Run tests in CI + +Set following environment variables: + +```shell +export STORAGE_OSS_INTEGRATION_TEST=on +export STORAGE_OSS_CREDENTIAL=hmac:access_key:secret_key +export STORAGE_OSS_NAME=bucketname +export STORAGE_OSS_ENDPOINT=https:oss-region-name.aliyuncs.com +``` + +Run tests + +```shell +make integration_test +``` diff --git a/tests/storage_test.go b/tests/storage_test.go index 2eb0faf..8f28b5e 100644 --- a/tests/storage_test.go +++ b/tests/storage_test.go @@ -1,13 +1,15 @@ -// +build integration_test - package tests import ( + "os" "testing" tests "github.com/aos-dev/go-integration-test/v3" ) func TestStorage(t *testing.T) { + if os.Getenv("STORAGE_OSS_INTEGRATION_TEST") != "on" { + t.Skipf("STORAGE_OSS_INTEGRATION_TEST is not 'on', skipped") + } tests.TestStorager(t, setupTest(t)) } diff --git a/tests/utils_test.go b/tests/utils_test.go index f13ae49..5d8c260 100644 --- a/tests/utils_test.go +++ b/tests/utils_test.go @@ -1,15 +1,13 @@ -// +build integration_test - package tests import ( "os" "testing" + oss "github.com/aos-dev/go-service-oss" ps "github.com/aos-dev/go-storage/v3/pairs" "github.com/aos-dev/go-storage/v3/types" "github.com/google/uuid" - oss "github.com/aos-dev/go-service-oss" ) func setupTest(t *testing.T) types.Storager { diff --git a/tools.go b/tools.go new file mode 100644 index 0000000..967a389 --- /dev/null +++ b/tools.go @@ -0,0 +1,5 @@ +//+build tools + +package oss + +import _ "github.com/aos-dev/go-storage/v3/cmd/definitions"