Skip to content

Commit

Permalink
Make Metadata tests to be controllable whether "run" or "skip" by an …
Browse files Browse the repository at this point in the history
…environment variable

Rel: #13
#13 (comment)
  • Loading branch information
moznion committed Apr 3, 2020
1 parent 79b9c72 commit f1790b0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,13 @@ func main() {
もう少し詳しい使い方は
http://qiita.com/bearmini/items/6e3f66bc0ef846c8d197
を参照してください。

## For developers

### how to run test

TBD

#### how to run test with metadata tests

Please run tests with not-empty environment variable `$METADATA_TEST_ENABLED`.
34 changes: 34 additions & 0 deletions metadata_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ var (
metadataClient *MetadataClient
)

var isMetaDataTestEnabled = os.Getenv("METADATA_TEST_ENABLED") != ""

func TestMetadataInit(t *testing.T) {
if !isMetaDataTestEnabled {
t.Skip("metadata testing is disabled")
}

endpoint := os.Getenv("SORACOM_METADATA_ENDPOINT")
options := &MetadataClientOptions{
Endpoint: endpoint,
Expand All @@ -24,13 +30,21 @@ func TestMetadataInit(t *testing.T) {
}

func TestMetadataGetSubscriber(t *testing.T) {
if !isMetaDataTestEnabled {
t.Skip("metadata testing is disabled")
}

_, err := metadataClient.GetSubscriber()
if err != nil {
t.Fatalf("GetSubscriber() failed: %v", err.Error())
}
}

func TestMetadataUdpateSpeedClass(t *testing.T) {
if !isMetaDataTestEnabled {
t.Skip("metadata testing is disabled")
}

sub, err := metadataClient.GetSubscriber()
if err != nil {
t.Fatalf("GetSubscriber() failed: %v", err.Error())
Expand Down Expand Up @@ -64,6 +78,10 @@ func TestMetadataUdpateSpeedClass(t *testing.T) {
}

func TestMetadataEnableDisableTermination(t *testing.T) {
if !isMetaDataTestEnabled {
t.Skip("metadata testing is disabled")
}

sub, err := metadataClient.GetSubscriber()
if err != nil {
t.Fatalf("GetSubscriber() failed: %v", err.Error())
Expand Down Expand Up @@ -108,6 +126,10 @@ func timeToUnixMilli(t time.Time) int64 {
}

func TestMetadataSetUnsetExpiredAt(t *testing.T) {
if !isMetaDataTestEnabled {
t.Skip("metadata testing is disabled")
}

sub, err := metadataClient.GetSubscriber()
if err != nil {
t.Fatalf("GetSubscriber() failed: %v", err.Error())
Expand Down Expand Up @@ -144,6 +166,10 @@ func TestMetadataSetUnsetExpiredAt(t *testing.T) {
}

func TestMetadataSetUnsetGroup(t *testing.T) {
if !isMetaDataTestEnabled {
t.Skip("metadata testing is disabled")
}

sub, err := metadataClient.GetSubscriber()
if err != nil {
t.Fatalf("GetSubscriber() failed: %v", err.Error())
Expand Down Expand Up @@ -176,6 +202,10 @@ func TestMetadataSetUnsetGroup(t *testing.T) {
}

func TestMetadataPutDeleteTags(t *testing.T) {
if !isMetaDataTestEnabled {
t.Skip("metadata testing is disabled")
}

n1 := "metadata-test-tag-name-1"
//n1 := "metadata test tag name 1" // half width spaces must be tested
v1 := "metadata test tag value 1"
Expand Down Expand Up @@ -236,6 +266,10 @@ func TestMetadataPutDeleteTags(t *testing.T) {
}

func TestMetadataGetUserdata(t *testing.T) {
if !isMetaDataTestEnabled {
t.Skip("metadata testing is disabled")
}

_, err := metadataClient.GetUserdata()
if err != nil {
t.Fatalf("GetUserdata() failed: %v", err.Error())
Expand Down

0 comments on commit f1790b0

Please sign in to comment.