Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/ddc/alluxio/operations/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,18 @@ func TestAlluxioFIleUtils_Du(t *testing.T) {
}
}

// TestAlluxioFileUtils_Count tests the Count method of AlluxioFileUtils.
// This function verifies the Count method's ability to parse the output of the alluxio fs count command
// and handle various error scenarios such as execution errors, negative results, too many lines,
// data number mismatches, and parse errors.
//
// Test cases:
// - EXEC_ERR: Tests handling of command execution errors.
// - NEGATIVE_RES: Tests handling of negative result values.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This comment states that the NEGATIVE_RES case tests handling of negative result values. However, the corresponding mock implementation for this test case returns a single line of output:

return "12324\t45463\t-9223372036854775808", "", nil

The Count function expects two lines of output (a header and a data line) and will fail on parsing if only one is provided. Therefore, this test case currently verifies handling of malformed output (incorrect number of lines), not the logic for handling negative values within the data itself.

To align the test with the comment, the mock should be updated to return two lines, ensuring the negative value check in the Count function is actually reached. For example:

return "File Count\tFolder Count\tTotal Bytes\n12324\t45463\t-9223372036854775808", "", nil

Since modifying the test logic is outside the scope of this PR, please consider either updating this comment to accurately describe the current test's behavior or addressing the test implementation in a separate PR.

// - TOO_MANY_LINES: Tests handling of output with too many lines.
// - DATA_NUM: Tests handling of mismatched data numbers.
// - PARSE_ERR: Tests handling of parse errors.
// - FINE: Tests successful parsing of count output.
func TestAlluxioFileUtils_Count(t *testing.T) {
out1, out2, out3 := 111, 222, 333
mockExec := func(ctx context.Context, p1, p2, p3 string, p4 []string) (stdout string, stderr string, e error) {
Expand Down
Loading