Skip to content

Commit

Permalink
add tests for directory
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwei committed Oct 5, 2023
1 parent 8afbcf5 commit 79fb658
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions internal/domain/arch/entity/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,27 @@ func TestGetObjs(t *testing.T) {
t.Errorf("Expected an error for invalid directory, got no error")
}
}

func TestParentDir(t *testing.T) {
// 创建一个模拟的 Directory 实例
dir := &Directory{}

// 测试目录
testCases := []struct {
inputDir string
expectedParentDir string
}{
{"/root/target", "root"},
{"/root", "/"},
{"/", "/"},
{"/root/dir/file.txt", "dir"},
}

for _, testCase := range testCases {
result := dir.ParentDir(testCase.inputDir)

if result != testCase.expectedParentDir {
t.Errorf("Expected parent directory %s for input directory %s, got %s", testCase.expectedParentDir, testCase.inputDir, result)
}
}
}

0 comments on commit 79fb658

Please sign in to comment.