You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "jrmccluskey (via GitHub)" <gi...@apache.org> on 2023/04/03 17:45:44 UTC

[GitHub] [beam] jrmccluskey commented on a diff in pull request #26065: Go SDK: GCS FS supports rename, improved test coverage. Local FS supports copy.

jrmccluskey commented on code in PR #26065:
URL: https://github.com/apache/beam/pull/26065#discussion_r1156160371


##########
sdks/go/pkg/beam/io/filesystem/gcs/gcs_test.go:
##########
@@ -36,3 +40,238 @@ func TestGCS_FilesystemNew(t *testing.T) {
 		t.Errorf("c.Close() = %v, want nil", err)
 	}
 }
+
+func TestGCS_direct(t *testing.T) {
+	ctx := context.Background()
+	dirPath := "gs://beamgogcsfilesystemtest"
+	filePath := dirPath + "/file.txt"
+
+	server := fakestorage.NewServer([]fakestorage.Object{
+		{
+			ObjectAttrs: fakestorage.ObjectAttrs{
+				BucketName: "beamgogcsfilesystemtest",
+				Name:       "stub",
+			},
+			Content: []byte(""),
+		},
+	})

Review Comment:
   Consider refactoring the creation of the mock storage system into a helper function since this block is reused often



##########
sdks/go/pkg/beam/io/filesystem/gcs/gcs_test.go:
##########
@@ -36,3 +40,238 @@ func TestGCS_FilesystemNew(t *testing.T) {
 		t.Errorf("c.Close() = %v, want nil", err)
 	}
 }
+
+func TestGCS_direct(t *testing.T) {
+	ctx := context.Background()
+	dirPath := "gs://beamgogcsfilesystemtest"
+	filePath := dirPath + "/file.txt"
+
+	server := fakestorage.NewServer([]fakestorage.Object{
+		{
+			ObjectAttrs: fakestorage.ObjectAttrs{
+				BucketName: "beamgogcsfilesystemtest",
+				Name:       "stub",
+			},
+			Content: []byte(""),
+		},
+	})
+	defer server.Stop()

Review Comment:
   Prefer using t.Cleanup() over defer, which lets you put the `server.Stop()` call into the helper function. See https://google.github.io/styleguide/go/decisions#test-helpers



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org