Skip to content

Commit

Permalink
Fixed tests by adding a random directory
Browse files Browse the repository at this point in the history
  • Loading branch information
codechanges committed Dec 23, 2024
1 parent 7968ddd commit 0043f39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/integration_tests/implicit_dir/local_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (
// //////////////////////////////////////////////////////////////////////

func TestNewFileUnderImplicitDirectoryShouldNotGetSyncedToGCSTillClose(t *testing.T) {
testDirPath = setup.SetupTestDirectory(testDirName)
testDirPath = setup.SetupTestDirectory(path.Join(testDirName, operations.GetRandomName(t)))
CreateImplicitDir(ctx, storageClient, testDirName, t)
fileName := path.Join(ImplicitDirName, FileName1)

Expand All @@ -50,7 +50,7 @@ func TestNewFileUnderImplicitDirectoryShouldNotGetSyncedToGCSTillClose(t *testin
}

func TestReadDirForImplicitDirWithLocalFile(t *testing.T) {
testDirPath = setup.SetupTestDirectory(testDirName)
testDirPath = setup.SetupTestDirectory(path.Join(testDirName, operations.GetRandomName(t)))
CreateImplicitDir(ctx, storageClient, testDirName, t)
fileName1 := path.Join(ImplicitDirName, FileName1)
fileName2 := path.Join(ImplicitDirName, FileName2)
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestRecursiveListingWithLocalFiles(t *testing.T) {
// mntDir/implicit/foo2 --- file
// mntDir/implicit/implicitFile1 --- file

testDirPath = setup.SetupTestDirectory(testDirName)
testDirPath = setup.SetupTestDirectory(path.Join(testDirName, operations.GetRandomName(t)))
fileName2 := path.Join(ExplicitDirName, ExplicitFileName1)
fileName3 := path.Join(ImplicitDirName, FileName2)
// Create local file in mnt/ dir.
Expand Down
10 changes: 10 additions & 0 deletions tools/integration_tests/util/operations/string_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package operations
import (
"strings"
"testing"

"github.com/google/uuid"
)

func VerifyExpectedSubstrings(t *testing.T, input string, expectedSubstrings []string) {
Expand All @@ -35,3 +37,11 @@ func VerifyUnexpectedSubstrings(t *testing.T, input string, unexpectedSubstrings
}
}
}

func GetRandomName(t *testing.T) string {
id, err := uuid.NewRandom()
if err != nil {
t.Errorf("Error while generating random string, err: %v", err)
}
return id.String()
}

0 comments on commit 0043f39

Please sign in to comment.