Skip to content

Commit

Permalink
remove dependence on create_objects.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
gargnitingoogle committed Jun 17, 2024
1 parent 9d088b3 commit e5b06b1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 31 deletions.
2 changes: 1 addition & 1 deletion tools/integration_tests/explicit_dir/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestListOnlyExplicitObjectsFromBucket(t *testing.T) {
// testBucket/dirForExplicitDirTests/explicitDirectory/fileInExplicitDir1 -- File
// testBucket/dirForExplicitDirTests/explicitDirectory/fileInExplicitDir2 -- File

implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForExplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForExplicitDirTests, t)
implicit_and_explicit_dir_setup.CreateExplicitDirectoryStructure(DirForExplicitDirTests, t)

err := filepath.WalkDir(testDir, func(path string, dir fs.DirEntry, err error) error {
Expand Down
8 changes: 4 additions & 4 deletions tools/integration_tests/implicit_dir/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
func TestDeleteNonEmptyImplicitDir(t *testing.T) {
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests, t)

dirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory)

Expand All @@ -45,7 +45,7 @@ func TestDeleteNonEmptyImplicitDir(t *testing.T) {
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
func TestDeleteNonEmptyImplicitSubDir(t *testing.T) {
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests, t)

subDirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory)

Expand All @@ -61,7 +61,7 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) {
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) {
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests, t)

explicitDirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir)

Expand All @@ -81,7 +81,7 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) {
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File
func TestDeleteImplicitDirWithImplicitSubDirContainingExplicitDir(t *testing.T) {
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests, t)
explicitDirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir)

operations.CreateDirectoryWithNFiles(NumberOfFilesInExplicitDirInImplicitSubDir, explicitDirPath, PrefixFileInExplicitDirInImplicitSubDir, t)
Expand Down
2 changes: 1 addition & 1 deletion tools/integration_tests/implicit_dir/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestListImplicitObjectsFromBucket(t *testing.T) {
// testBucket/dirForImplicitDirTests// -- Dir
// testBucket/dirForImplicitDirTests//fileInUnsupportedImplicitDir1 -- File

implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests, t)
implicit_and_explicit_dir_setup.CreateExplicitDirectoryStructure(DirForImplicitDirTests, t)
implicit_and_explicit_dir_setup.CreateUnsupportedImplicitDirectoryStructure(DirForImplicitDirTests, t)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,20 @@ func createObjectOnGcs(content, completeObjectName string, t *testing.T) {
}
}

func CreateImplicitDirectoryStructure(testDir string) {
func createObjectsInImplicitDir(implicitDirName string, t *testing.T) {
createObjectOnGcs("This is from directory fileInImplicitDir1 file implicitDirectory", path.Join(implicitDirName, FileInImplicitDirectory), t)
createObjectOnGcs("This is from directory implicitDirectory/implicitSubDirectory file fileInImplicitDir2", path.Join(implicitDirName, ImplicitSubDirectory, FileInImplicitSubDirectory), t)
}

func CreateImplicitDirectoryStructure(testDir string, t *testing.T) {
// Implicit Directory Structure
// testBucket/testDir/implicitDirectory -- Dir
// testBucket/testDir/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/testDir/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/testDir/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File

// Create implicit directory in bucket for testing.
setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_objects.sh", path.Join(setup.TestBucket(), testDir))
createObjectsInImplicitDir(path.Join(testDir, ImplicitDirectory), t)
}

func CreateUnsupportedImplicitDirectoryStructure(testDir string, t *testing.T) {
Expand Down Expand Up @@ -148,6 +153,5 @@ func CreateImplicitDirectoryInExplicitDirectoryStructure(testDir string, t *test
// testBucket/testDir/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File

CreateExplicitDirectoryStructure(testDir, t)
dirPathInBucket := path.Join(setup.TestBucket(), testDir, ExplicitDirectory)
setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_objects.sh", dirPathInBucket)
createObjectsInImplicitDir(path.Join(testDir, ExplicitDirectory, ImplicitDirectory), t)
}

This file was deleted.

0 comments on commit e5b06b1

Please sign in to comment.