Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prism] Simpler io changes to add TestMain. #27587

Merged
merged 1 commit into from
Jul 21, 2023
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
5 changes: 5 additions & 0 deletions sdks/go/pkg/beam/io/bigtableio/bigtable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ import (

"cloud.google.com/go/bigtable"
"github.com/apache/beam/sdks/v2/go/pkg/beam"
"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/ptest"
)

func TestMain(m *testing.M) {
ptest.Main(m)
}

func TestHashStringToInt(t *testing.T) {
equalVal := "equal"

Expand Down
4 changes: 4 additions & 0 deletions sdks/go/pkg/beam/io/databaseio/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
_ "github.com/proullon/ramsql/driver"
)

func TestMain(m *testing.M) {
ptest.Main(m)
}

type Address struct {
Street string
Street_number int
Expand Down
6 changes: 6 additions & 0 deletions sdks/go/pkg/beam/io/fhirio/deidentify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import (
"google.golang.org/api/healthcare/v1"
)

func TestMain(m *testing.M) {
// TODO(https://github.com/apache/beam/issues/27547): Make tests compatible with portable runners.
// To work on this change, replace call with `ptest.Main(m)`
ptest.MainWithDefault(m, "direct")
}

func TestDeidentify_Error(t *testing.T) {
p, s := beam.NewPipelineWithRoot()
out := deidentify(s, "src", "dst", nil, requestReturnErrorFakeClient)
Expand Down
4 changes: 4 additions & 0 deletions sdks/go/pkg/beam/io/fileio/match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
"github.com/google/go-cmp/cmp"
)

func TestMain(m *testing.M) {
ptest.Main(m)
}

type testFile struct {
filename string
data []byte
Expand Down
4 changes: 4 additions & 0 deletions sdks/go/pkg/beam/io/parquetio/parquetio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import (
"github.com/xitongsys/parquet-go/reader"
)

func TestMain(m *testing.M) {
ptest.Main(m)
}

type Student struct {
Name string `parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
Age int32 `parquet:"name=age, type=INT32, encoding=PLAIN"`
Expand Down
18 changes: 11 additions & 7 deletions sdks/go/pkg/beam/io/textio/textio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@
package textio

import (
"context"
"errors"
"os"
"path/filepath"
"testing"

"github.com/apache/beam/sdks/v2/go/pkg/beam"
_ "github.com/apache/beam/sdks/v2/go/pkg/beam/io/filesystem/local"
"github.com/apache/beam/sdks/v2/go/pkg/beam/register"
"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/passert"
"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/ptest"
)

func TestMain(m *testing.M) {
ptest.Main(m)
}

func init() {
register.Function2x1(toKV)
}

const testDir = "../../../../data"

var (
Expand Down Expand Up @@ -144,9 +152,7 @@ func TestReadSdf(t *testing.T) {
lines := ReadSdf(s, testFilePath)
passert.Count(s, lines, "NumLines", 1)

if _, err := beam.Run(context.Background(), "direct", p); err != nil {
t.Fatalf("Failed to execute job: %v", err)
}
ptest.RunAndValidate(t, p)
}

func TestReadAllSdf(t *testing.T) {
Expand All @@ -155,7 +161,5 @@ func TestReadAllSdf(t *testing.T) {
lines := ReadAllSdf(s, files)
passert.Count(s, lines, "NumLines", 1)

if _, err := beam.Run(context.Background(), "direct", p); err != nil {
t.Fatalf("Failed to execute job: %v", err)
}
ptest.RunAndValidate(t, p)
}
4 changes: 4 additions & 0 deletions sdks/go/pkg/beam/x/debug/head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import (
"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/ptest"
)

func TestMain(m *testing.M) {
ptest.Main(m)
}

func TestHead(t *testing.T) {
p, s, sequence := ptest.CreateList([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
headSequence := Head(s, sequence, 5)
Expand Down