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/cached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ func TestAlluxioFileUtils_CachedState(t *testing.T) {
}
}

// TestAlluxioFIlUtils_CleanCache tests the CleanCache function of AlluxioFileUtils.
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

The function name TestAlluxioFIlUtils_CleanCache contains a typo (FIlUtils instead of FileUtils). This typo should be corrected in the function declaration as well as in this documentation comment to maintain consistency with the rest of the codebase (e.g., TestAlluxioFileUtils_CachedState).

Suggested change
// TestAlluxioFIlUtils_CleanCache tests the CleanCache function of AlluxioFileUtils.
// TestAlluxioFileUtils_CleanCache tests the CleanCache function of AlluxioFileUtils.
References
  1. Go naming conventions suggest using consistent and correctly spelled names for functions and types to ensure readability and maintainability. (link)

// It uses gomonkey to mock the exec function and simulates different scenarios, including command execution failure and successful execution on both Ubuntu and Alpine systems.
// The test checks if the CleanCache function correctly handles errors and returns the expected results based on the mocked exec function's output.
// The test cases include:
// 1. Simulating a command execution failure and verifying that the CleanCache function returns an error.
// 2. Simulating a successful command execution on an Ubuntu system and verifying that the CleanCache function returns nil (indicating success).
// 3. Simulating a successful command execution on an Alpine system and verifying that the CleanCache function returns nil (indicating success).

// parameters:
// - t: The testing object used to report test failures and log information during the test execution.
// returns:
// - None. The function uses the testing object to report results and does not return any value.
Comment on lines +61 to +65
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

In Go, documentation comments should be placed immediately before the function declaration without any intervening blank lines. Additionally, documenting standard parameters like *testing.T and return values for test functions is considered redundant and is not idiomatic Go style. Removing these lines will make the documentation more concise and idiomatic.

References
  1. Go Code Review Comments states that doc comments should be followed immediately by the declaration, with no intervening blank line, and that comments should be concise and avoid redundant information. (link)

func TestAlluxioFIlUtils_CleanCache(t *testing.T) {
ExecCommonUbuntu := func(a AlluxioFileUtils, command []string, verbose bool) (stdout string, stderr string, err error) {
return "Ubuntu", "", nil
Expand Down