Skip to content

Commit

Permalink
Remove setup
Browse files Browse the repository at this point in the history
  • Loading branch information
KeisukeYamashita committed Dec 7, 2019
1 parent 5606781 commit 89d56c9
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions reporter/gcppubsub/pubsub_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package gcppubsub

import (
"context"
"errors"
"fmt"
"log"
"os"
"testing"
Expand All @@ -16,18 +14,6 @@ import (

var topicID string

func setup(t *testing.T, topicID string) *pubsub.Client {
ctx := context.Background()
proj := os.Getenv("GOOGLE_CLOUD_PROJECT")
fmt.Printf("GCP Project: %s\n", proj)

client, err := pubsub.NewClient(ctx, proj)
if err != nil {
t.Fatalf("failed to create client: %s\n", topicID)
}
return client
}

func TestPublish(t *testing.T) {
tcs := map[string]struct {
topicID string
Expand All @@ -42,8 +28,8 @@ func TestPublish(t *testing.T) {

for n, tc := range tcs {
t.Run(n, func(t *testing.T) {
c := setup(t, tc.topicID)
top := c.Topic(topicID)
c := &pubsub.Client{}
top := c.Topic(tc.topicID)
reporter, err := newStubReporter(Client(c), Topic(top))
if err != nil {
t.Fatalf("failed creating reporter: %v", err)
Expand Down Expand Up @@ -121,7 +107,7 @@ func TestLogger(t *testing.T) {

for n, tc := range tcs {
t.Run(n, func(t *testing.T) {
c := setup(t, defaultPubSubTopic)
c := &pubsub.Client{}
_, err := newStubReporter(Client(c), Logger(tc.logger))
if err != nil {
t.Fatalf("failed creating reporter with logger: %v", err)
Expand Down

0 comments on commit 89d56c9

Please sign in to comment.