Skip to content

Commit 8d75c78

Browse files
authored
test: release init to handle symbolic links (#1895)
command to run the test: go test -race ./internal/librarian/... -run "TestInitRun/run release init command with symbolic link" Fixes #1847 Actually the fix was already in the use of Go 1.25 (suztomo@89e17ef). This pull request ensures the fix is continue to be there as a test.
1 parent 7e66923 commit 8d75c78

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

internal/librarian/release_init_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,35 @@ func TestInitRun(t *testing.T) {
334334
wantErr: true,
335335
wantErrMsg: "failed to make directory",
336336
},
337+
{
338+
name: "run release init command with symbolic link",
339+
runner: &initRunner{
340+
workRoot: t.TempDir(),
341+
containerClient: &mockContainerClient{},
342+
cfg: &config.Config{
343+
Library: "example-id",
344+
Push: false,
345+
},
346+
state: &config.LibrarianState{
347+
Libraries: []*config.LibraryState{
348+
{
349+
ID: "example-id",
350+
SourceRoots: []string{
351+
"dir1",
352+
},
353+
},
354+
},
355+
},
356+
repo: &MockRepository{
357+
Dir: t.TempDir(),
358+
},
359+
librarianConfig: &config.LibrarianConfig{},
360+
partialRepo: t.TempDir(),
361+
},
362+
files: map[string]string{
363+
"dir1/file1.txt": "hello",
364+
},
365+
},
337366
} {
338367
t.Run(test.name, func(t *testing.T) {
339368
// Setup library files before running the command.
@@ -352,6 +381,13 @@ func TestInitRun(t *testing.T) {
352381
}
353382
}
354383
}
384+
// Create a symbolic link for the test case with symbolic links.
385+
if test.name == "run release init command with symbolic link" {
386+
if err := os.Symlink(filepath.Join(repoDir, "dir1/file1.txt"),
387+
filepath.Join(repoDir, "dir1/symlink.txt")); err != nil {
388+
t.Fatalf("os.Symlink() = %v", err)
389+
}
390+
}
355391
librarianDir := filepath.Join(repoDir, ".librarian")
356392
if err := os.MkdirAll(librarianDir, 0755); err != nil {
357393
t.Fatalf("os.MkdirAll() = %v", err)

0 commit comments

Comments
 (0)