Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit 0896875

Browse files
authored
ci: Implement integration tests (#2)
Signed-off-by: Xuanwo <[email protected]>
1 parent 6d24a26 commit 0896875

File tree

9 files changed

+95
-6
lines changed

9 files changed

+95
-6
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Integration Test"
2+
3+
on: [push,pull_request]
4+
5+
jobs:
6+
integration_test:
7+
name: "Integration Test"
8+
runs-on: [Linux]
9+
10+
strategy:
11+
matrix:
12+
go: [ "1.15", "1.16" ]
13+
14+
steps:
15+
- name: Set up Go 1.x
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: ${{ matrix.go }}
19+
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
23+
- name: Test
24+
env:
25+
STORAGE_AZBLOB_CREDENTIAL: ${{ secrets.STORAGE_AZBLOB_CREDENTIAL }}
26+
STORAGE_AZBLOB_NAME: ${{ secrets.STORAGE_AZBLOB_NAME }}
27+
STORAGE_AZBLOB_ENDPOINT: ${{ secrets.STORAGE_AZBLOB_ENDPOINT }}
28+
run: make integration_test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
coverage.*
2-
bin/
2+
bin/
3+
Makefile.env

Makefile.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export STORAGE_AZBLOB_CREDENTIAL=hmac:access_key:secret_key
2+
export STORAGE_AZBLOB_NAME=bucketname
3+
export STORAGE_AZBLOB_ENDPOINT=https:oss-region-name.aliyuncs.com

generated.go

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ go 1.15
55
require (
66
github.com/Azure/azure-pipeline-go v0.2.2
77
github.com/Azure/azure-storage-blob-go v0.10.0
8+
github.com/aos-dev/go-integration-test/v3 v3.0.0-20210205075620-0b779f4b3afc
89
github.com/aos-dev/go-storage/v3 v3.0.1-0.20210209045525-d1e648506cdf
10+
github.com/google/uuid v1.2.0
911
)

go.sum

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VY
2020
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
2121
github.com/Xuanwo/templateutils v0.0.0-20201019101431-c73b871118f2 h1:ydpBZm38sXcYOVKjmfYOy66UneSh/brXGS3LQrTvaAc=
2222
github.com/Xuanwo/templateutils v0.0.0-20201019101431-c73b871118f2/go.mod h1:x0qS7gfgEm24b8V9U+0zBEBAu/VpxZhO/+EWtpgEgDw=
23+
github.com/aos-dev/go-integration-test/v3 v3.0.0-20210205075620-0b779f4b3afc h1:s8BQqJwWe2yoTGJFOsIxnkwwMsnDqMgkO39yzEP4smw=
24+
github.com/aos-dev/go-integration-test/v3 v3.0.0-20210205075620-0b779f4b3afc/go.mod h1:2VqxZhJVvI1jKTTERWHfCBMZQaJt10xoEJ+CxbfYZlo=
25+
github.com/aos-dev/go-storage/v3 v3.0.1-0.20210205074802-e8a5b22166c2/go.mod h1:JznhvyhPDnETfZ3RyWm3mT/S5ic+uuYFWagSIkUZujc=
2326
github.com/aos-dev/go-storage/v3 v3.0.1-0.20210209045525-d1e648506cdf h1:OFpGHyh91cmD8fomQ5cUPJf0Fy2NdrjYr14nhFvk9eU=
2427
github.com/aos-dev/go-storage/v3 v3.0.1-0.20210209045525-d1e648506cdf/go.mod h1:JznhvyhPDnETfZ3RyWm3mT/S5ic+uuYFWagSIkUZujc=
2528
github.com/aos-dev/specs/go v0.0.0-20210205073047-af8ef94af73d h1:NKktDzsApKM0VtGkDkJHr6fPHbQjHw7BpR8UxeCUNLs=
@@ -42,7 +45,10 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
4245
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
4346
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
4447
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
48+
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
4549
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
50+
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
51+
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
4652
github.com/kevinburke/go-bindata v3.22.0+incompatible h1:/JmqEhIWQ7GRScV0WjX/0tqBrC5D21ALg0H0U/KZ/ts=
4753
github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
4854
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
@@ -59,6 +65,10 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
5965
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6066
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
6167
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
68+
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
69+
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
70+
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
71+
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
6272
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6373
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
6474
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
@@ -82,6 +92,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5
8292
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8393
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
8494
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
95+
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
8596
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
8697
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
8798
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5 h1:MeC2gMlMdkd67dn17MEby3rGXRxZtWeiRXOnISfTQ74=

service.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name = "azblob"
33
[namespace.service]
44

55
[namespace.service.new]
6-
required = ["credential"]
7-
optional = ["endpoint", "http_client_options", "pair_policy"]
6+
required = ["credential", "endpoint"]
7+
optional = ["http_client_options", "pair_policy"]
88

99
[namespace.storage.new]
1010
required = ["name"]

tests/storage_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// +build integration_test
2+
3+
package tests
4+
5+
import (
6+
"testing"
7+
8+
tests "github.com/aos-dev/go-integration-test/v3"
9+
)
10+
11+
func TestStorage(t *testing.T) {
12+
tests.TestStorager(t, setupTest(t))
13+
}

tests/utils_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// +build integration_test
2+
3+
package tests
4+
5+
import (
6+
"os"
7+
"testing"
8+
9+
ps "github.com/aos-dev/go-storage/v3/pairs"
10+
"github.com/aos-dev/go-storage/v3/types"
11+
"github.com/google/uuid"
12+
azblob "github.com/aos-dev/go-service-azblob"
13+
)
14+
15+
func setupTest(t *testing.T) types.Storager {
16+
t.Log("Setup test for azblob")
17+
18+
store, err := azblob.NewStorager(
19+
ps.WithCredential(os.Getenv("STORAGE_AZBLOB_CREDENTIAL")),
20+
ps.WithName(os.Getenv("STORAGE_AZBLOB_NAME")),
21+
ps.WithEndpoint(os.Getenv("STORAGE_AZBLOB_ENDPOINT")),
22+
ps.WithWorkDir("/"+uuid.New().String()+"/"),
23+
)
24+
if err != nil {
25+
t.Errorf("new storager: %v", err)
26+
}
27+
return store
28+
}

0 commit comments

Comments
 (0)