This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
generated from beyondstorage/go-service-example
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export STORAGE_OBS_INTEGRATION_TEST=on | ||
export STORAGE_OBS_CREDENTIAL=hmac:access_key:secret_key | ||
export STORAGE_OBS_NAME=bucketname | ||
export STORAGE_OBS_ENDPOINT=https:obs.<region>.myhuaweicloud.com |
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
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,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_OBS_INTEGRATION_TEST=on | ||
export STORAGE_OBS_CREDENTIAL=hmac:access_key:secret_key | ||
export STORAGE_OBS_NAME=bucketname | ||
export STORAGE_OBS_ENDPOINT=https:obs.<region>.myhuaweicloud.com | ||
``` | ||
|
||
Run tests | ||
|
||
```shell | ||
make integration_test | ||
``` |
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,15 @@ | ||
package tests | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
tests "github.com/beyondstorage/go-integration-test/v4" | ||
) | ||
|
||
func TestStorage(t *testing.T) { | ||
if os.Getenv("STORAGE_OBS_INTEGRATION_TEST") != "on" { | ||
t.Skipf("STORAGE_OBS_INTEGRATION_TEST is not 'on', skipped") | ||
} | ||
tests.TestStorager(t, setupTest(t)) | ||
} |
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,31 @@ | ||
package tests | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/google/uuid" | ||
|
||
obs "github.com/beyondstorage/go-service-obs" | ||
ps "github.com/beyondstorage/go-storage/v4/pairs" | ||
"github.com/beyondstorage/go-storage/v4/types" | ||
) | ||
|
||
func setupTest(t *testing.T) types.Storager { | ||
t.Log("Setup test for obs") | ||
|
||
store, err := obs.NewStorager( | ||
ps.WithCredential(os.Getenv("STORAGE_OBS_CREDENTIAL")), | ||
ps.WithName(os.Getenv("STORAGE_OBS_NAME")), | ||
ps.WithEndpoint(os.Getenv("STORAGE_OBS_ENDPOINT")), | ||
ps.WithWorkDir("/"+uuid.New().String()+"/"), | ||
obs.WithStorageFeatures(obs.StorageFeatures{ | ||
VirtualDir: true, | ||
}), | ||
) | ||
if err != nil { | ||
t.Errorf("new storager: %v", err) | ||
} | ||
|
||
return store | ||
} |