Skip to content

Commit

Permalink
Integration tests should time out of operation fails to complete in 5
Browse files Browse the repository at this point in the history
seconds (aka if datastore emulator is not running or cannot be reached).
  • Loading branch information
Kami committed Aug 14, 2019
1 parent 2cdeb1d commit fbfc329
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions datastore-translator/translator_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ import (
"gotest.tools/assert"
"log"
"testing"
"time"
)

func TestIntegration(t *testing.T) {
ctx := context.Background()

// 1. create a new datastore client
client, err := datastore.NewClient(ctx, "st2-saas-prototype-dev")
assert.NilError(t, err)

ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

// 2. create a key that we plan to save into
key := datastore.NameKey("Example_DB_Model", "complex_proto_2", nil)

Expand Down Expand Up @@ -120,6 +125,9 @@ func TestEmptyProtoMessage(t *testing.T) {
client, err := datastore.NewClient(ctx, "st2-saas-prototype-dev")
assert.NilError(t, err)

ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

// 2. create a key that we plan to save into
key := datastore.NameKey("Example_DB_Model", "complex_proto_empty", nil)

Expand Down Expand Up @@ -149,6 +157,9 @@ func TestProtoWithNilPointer(t *testing.T) {
client, err := datastore.NewClient(ctx, "st2-saas-prototype-dev")
assert.NilError(t, err)

ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

// 2. create a key that we plan to save into
key := datastore.NameKey("Example_DB_Model", "complex_proto_empty", nil)

Expand Down

0 comments on commit fbfc329

Please sign in to comment.