lostluck commented on a change in pull request #16937:
URL: https://github.com/apache/beam/pull/16937#discussion_r815201852



##########
File path: sdks/go/pkg/beam/io/textio/textio_test.go
##########
@@ -40,3 +46,68 @@ func TestRead(t *testing.T) {
        }
 
 }
+
+func TestRead(t *testing.T) {
+       p, s := beam.NewPipelineWithRoot()
+       lines := Read(s, testFilePath)
+       passert.Count(s, lines, "NumLines", 1)
+
+       if _, err := beam.Run(context.Background(), "direct", p); err != nil {

Review comment:
       Please change these to use the ptest helpers for executing pipeline 
instead of the normal infrastructure, and explicitly leaning on the direct 
runner. In particular: 
[ptest.RunAndValidate](https://pkg.go.dev/github.com/apache/beam/sdks/[email protected]/go/pkg/beam/testing/ptest#RunAndValidate)
   

##########
File path: sdks/go/pkg/beam/io/textio/textio_test.go
##########
@@ -40,3 +46,68 @@ func TestRead(t *testing.T) {
        }
 
 }
+
+func TestRead(t *testing.T) {
+       p, s := beam.NewPipelineWithRoot()
+       lines := Read(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)
+       }
+}
+
+func TestReadAll(t *testing.T) {
+       p, s := beam.NewPipelineWithRoot()
+       files := beam.Create(s, testFilePath)
+       lines := ReadAll(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)
+       }
+}
+
+func TestWrite(t *testing.T) {
+       out := "text.txt"
+       p, s := beam.NewPipelineWithRoot()
+       lines := Read(s, testFilePath)
+       Write(s, out, lines)
+
+       if _, err := beam.Run(context.Background(), "direct", p); err != nil {
+               t.Fatalf("Failed to execute job: %v", err)
+       }
+
+       if _, err := os.Stat(out); errors.Is(err, os.ErrNotExist) {
+               t.Fatalf("Failed to write %v", out)
+       }
+       defer os.Remove(out)

Review comment:
       Prefer using [t.Cleanup](https://pkg.go.dev/testing#T.Cleanup) instead 
of defer in tests, since then the cleanup will happen after test completion.
   
   In this case it's identical (when the function scope is exited), but it can 
occasionally not be.




-- 
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]


Reply via email to