Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

go: use time.UnixNano instead of testutil.UIDSpace #1279

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ public String getSmokeTestClassName(GapicInterfaceConfig interfaceConfig) {

@Override
public String injectRandomStringGeneratorCode(String randomString) {
return randomString.replace(InitFieldConfig.RANDOM_TOKEN, "\" + uidSpace.New() + \"");
return randomString.replace(
InitFieldConfig.RANDOM_TOKEN, "\" + strconv.FormatInt(time.Now().UnixNano(), 10) + \"");
}
}
7 changes: 5 additions & 2 deletions src/main/resources/com/google/api/codegen/go/smoke.snip
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
)

import (
"strconv"
"testing"
"time"

"cloud.google.com/go/internal/testutil"
"golang.org/x/net/context"
Expand All @@ -20,6 +22,8 @@
)

var _ = iterator.Done
var _ = strconv.FormatUint
var _ = time.Now

func {@view.name}(t *testing.T) {
if testing.Short() {
Expand All @@ -32,8 +36,7 @@
}

projectId := testutil.ProjID()
uidSpace := testutil.NewUIDSpace("{@view.name}")
_, _ = projectId, uidSpace
_ = projectId

c, err := {@view.method.serviceConstructorName}(ctx, option.WithTokenSource(ts))
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
)

import (
"strconv"
"testing"
"time"

"cloud.google.com/go/internal/testutil"
"golang.org/x/net/context"
Expand All @@ -31,6 +33,8 @@ import (
)

var _ = iterator.Done
var _ = strconv.FormatUint
var _ = time.Now

func TestLibraryServiceSmoke(t *testing.T) {
if testing.Short() {
Expand All @@ -43,15 +47,14 @@ func TestLibraryServiceSmoke(t *testing.T) {
}

projectId := testutil.ProjID()
uidSpace := testutil.NewUIDSpace("TestLibraryServiceSmoke")
_, _ = projectId, uidSpace
_ = projectId

c, err := NewClient(ctx, option.WithTokenSource(ts))
if err != nil {
t.Fatal(err)
}

var formattedName string = LibraryBookPath("testShelf-" + uidSpace.New() + "", projectId)
var formattedName string = LibraryBookPath("testShelf-" + strconv.FormatInt(time.Now().UnixNano(), 10) + "", projectId)
var rating librarypb.Book_Rating = librarypb.Book_GOOD
var book = &librarypb.Book{
Rating: rating,
Expand Down