5
5
package queue
6
6
7
7
import (
8
- "context"
9
- "os"
10
8
"testing"
11
9
"time"
12
10
@@ -39,15 +37,15 @@ func TestNewTaskID(t *testing.T) {
39
37
func TestNewTaskRequest (t * testing.T ) {
40
38
for _ , test := range []struct {
41
39
name string
42
- env map [ string ] string
40
+ cfg config. Config
43
41
want * taskspb.CreateTaskRequest
44
42
}{
45
43
{
46
44
"AppEngine" ,
47
- map [ string ] string {
48
- "GOOGLE_CLOUD_PROJECT" : "Project" ,
49
- "GAE_SERVICE" : "Service " ,
50
- "GAE_ENV" : "standard " ,
45
+ config. Config {
46
+ ProjectID : "Project" ,
47
+ LocationID : "us-central1 " ,
48
+ QueueService : "Service " ,
51
49
},
52
50
& taskspb.CreateTaskRequest {
53
51
Parent : "projects/Project/locations/us-central1/queues/queueID" ,
@@ -66,9 +64,10 @@ func TestNewTaskRequest(t *testing.T) {
66
64
},
67
65
{
68
66
"non-AppEngine" ,
69
- map [string ]string {
70
- "GOOGLE_CLOUD_PROJECT" : "Project" ,
71
- "GO_DISCOVERY_QUEUE_URL" : "http://1.2.3.4:8000" ,
67
+ config.Config {
68
+ ProjectID : "Project" ,
69
+ LocationID : "us-central1" ,
70
+ QueueURL : "http://1.2.3.4:8000" ,
72
71
},
73
72
& taskspb.CreateTaskRequest {
74
73
Parent : "projects/Project/locations/us-central1/queues/queueID" ,
@@ -84,18 +83,7 @@ func TestNewTaskRequest(t *testing.T) {
84
83
},
85
84
} {
86
85
t .Run (test .name , func (t * testing.T ) {
87
- for vari , val := range test .env {
88
- vari := vari
89
- prev := os .Getenv (vari )
90
- os .Setenv (vari , val )
91
- defer func () { os .Setenv (vari , prev ) }()
92
- }
93
-
94
- cfg , err := config .Init (context .Background ())
95
- if err != nil {
96
- t .Fatal (err )
97
- }
98
- gcp , err := newGCP (cfg , nil , "queueID" )
86
+ gcp , err := newGCP (& test .cfg , nil , "queueID" )
99
87
if err != nil {
100
88
t .Fatal (err )
101
89
}
0 commit comments