[
https://issues.apache.org/jira/browse/BEAM-6744?focusedWorklogId=718134&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-718134
]
ASF GitHub Bot logged work on BEAM-6744:
----------------------------------------
Author: ASF GitHub Bot
Created on: 31/Jan/22 18:07
Start Date: 31/Jan/22 18:07
Worklog Time Spent: 10m
Work Description: lostluck commented on a change in pull request #16643:
URL: https://github.com/apache/beam/pull/16643#discussion_r795933968
##########
File path: sdks/go/pkg/beam/options/gcpopts/options_test.go
##########
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package gcpopts
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "testing"
+)
+
+func TestGetProjectFromFlagOrEnvironmentWithNoProjectSet(t *testing.T) {
+ setupFakeCredentialFile(t, "")
+ *Project = ""
+ projectId := GetProjectFromFlagOrEnvironment(nil)
+ if projectId != "" {
+ t.Fatalf("%q returned as project id, should be \"\"", projectId)
+ }
+}
+
+func TestGetProjectFromFlagOrEnvironmentWithProjectFlagSet(t *testing.T) {
+ setupFakeCredentialFile(t, "")
+ *Project = "test"
+ projectId := GetProjectFromFlagOrEnvironment(nil)
+ if projectId != "test" {
+ t.Fatalf("%q returned as project id, should be \"test\"",
projectId)
+ }
+}
+
+func TestGetProjectFromFlagOrEnvironmentWithNoProjectFlagSetAndFallbackSet(t
*testing.T) {
+ setupFakeCredentialFile(t, "fallback")
+ *Project = ""
+ projectId := GetProjectFromFlagOrEnvironment(nil)
+ if projectId != "fallback" {
+ t.Fatalf("%q returned as project id, should be \"fallback\"",
projectId)
+ }
+}
+
+func TestGetProjectFromFlagOrEnvironmentWithProjectFlagSetAndFallbackSet(t
*testing.T) {
+ setupFakeCredentialFile(t, "fallback")
+ *Project = "test"
+ projectId := GetProjectFromFlagOrEnvironment(nil)
+ if projectId == "fallback" {
+ t.Fatalf("fallback returned as project id, should have used the
flag setting of \"test\"")
+ } else if projectId != "test" {
+ t.Fatalf("%q returned as project id, should be \"test\"",
projectId)
+ }
+}
+
+// Set up fake credential file to read project from with the passed in
projectId.
+func setupFakeCredentialFile(t *testing.T, projectId string) {
Review comment:
Ultimately, Go tries to allow you to use as much of Go as possible when
writing your tests and such. This one is a limited case technically. What the
"t.Helper()" call does is cause a failure to be reported at the helper's Call
Site, rather than at which line in the helper failed. Eg. If one has customized
a check and is using it repeatedly, this lets one know which call to the helper
failed.
Limited utility here, but a good habit to get into nonetheless.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 718134)
Time Spent: 1.5h (was: 1h 20m)
> Go SDK Dataflow Runner should support implicit authentication
> -------------------------------------------------------------
>
> Key: BEAM-6744
> URL: https://issues.apache.org/jira/browse/BEAM-6744
> Project: Beam
> Issue Type: Improvement
> Components: sdk-go
> Reporter: Robert Burke
> Assignee: Danny McCormick
> Priority: P3
> Labels: starter
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> The dataflow.go runner current requires a project to be set via a flag.
> However GCP supports implicit authentication which can be more convinient for
> users and infrastructure alike.
> Instructions for handling this are available at
> [https://cloud.google.com/docs/authentication/production#auth-cloud-implicit-go]
>
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)