You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by lo...@apache.org on 2022/11/05 16:55:54 UTC
[beam] 08/12: Add missing test coverage.
This is an automated email from the ASF dual-hosted git repository.
lostluck pushed a commit to branch beam23893pipelinehint
in repository https://gitbox.apache.org/repos/asf/beam.git
commit 02592b73e0c2652246a241242d97bead1d03e38a
Author: lostluck <13...@users.noreply.github.com>
AuthorDate: Fri Nov 4 15:43:09 2022 -0700
Add missing test coverage.
---
sdks/go/pkg/beam/options/jobopts/options_test.go | 28 ++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/sdks/go/pkg/beam/options/jobopts/options_test.go b/sdks/go/pkg/beam/options/jobopts/options_test.go
index a3118c8926f..eff629899b7 100644
--- a/sdks/go/pkg/beam/options/jobopts/options_test.go
+++ b/sdks/go/pkg/beam/options/jobopts/options_test.go
@@ -69,32 +69,41 @@ func TestGetJobName(t *testing.T) {
}
}
+// Also tests IsLoopback because it uses the same flag.
func TestGetEnvironmentUrn(t *testing.T) {
tests := []struct {
- env string
- urn string
+ env string
+ urn string
+ isLoopback bool
}{
{
"PROCESS",
"beam:env:process:v1",
+ false,
},
{
"DOCKER",
"beam:env:docker:v1",
+ false,
},
{
"LOOPBACK",
"beam:env:external:v1",
+ true,
},
{
"",
"beam:env:docker:v1",
+ false,
},
}
for _, test := range tests {
EnvironmentType = &test.env
- if gotUrn := GetEnvironmentUrn(context.Background()); gotUrn != test.urn {
- t.Errorf("GetEnvironmentUrn(ctx) = %v, want %v", gotUrn, test.urn)
+ if got, want := GetEnvironmentUrn(context.Background()), test.urn; got != want {
+ t.Errorf("GetEnvironmentUrn(%v) = %v, want %v", test.env, got, want)
+ }
+ if got, want := IsLoopback(), test.isLoopback; got != want {
+ t.Errorf("IsLoopback(%v) = %v, want %v", test.env, got, want)
}
}
}
@@ -147,3 +156,14 @@ func TestGetPipelineResourceHints(t *testing.T) {
t.Errorf("GetPipelineResourceHints() = %v, want %v", got, want)
}
}
+
+func TestGetExperiements(t *testing.T) {
+ *Experiments = ""
+ if got, want := GetExperiments(), []string(nil); !reflect.DeepEqual(got, want) {
+ t.Errorf("GetExperiments(\"\") = %v, want %v", got, want)
+ }
+ *Experiments = "better,faster,stronger"
+ if got, want := GetExperiments(), []string{"better", "faster", "stronger"}; !reflect.DeepEqual(got, want) {
+ t.Errorf("GetExperiments(\"\") = %v, want %v", got, want)
+ }
+}