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
6 changes: 6 additions & 0 deletions pkg/ddc/efc/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)


// TestSyncMetadataInternal tests the syncMetadataInternal method of EFCEngine.
// It verifies the method's behavior under different scenarios:
// 1. When TotalStorageBytes returns an error
// 2. When TotalFileNums returns an error
// 3. When both TotalStorageBytes and TotalFileNums succeed
Comment on lines +32 to +36
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 accurately describes the different scenarios this test covers. To improve the test's structure, readability, and maintainability, consider refactoring it to use subtests with t.Run for each scenario. This provides clearer output on failures and makes the test structure more explicit.

For example:

func TestSyncMetadataInternal(t *testing.T) {
    // ... setup ...

    t.Run("TotalStorageBytes returns an error", func(t *testing.T) {
        // ... test logic for this case ...
    })

    t.Run("TotalFileNums returns an error", func(t *testing.T) {
        // ... test logic for this case ...
    })

    t.Run("Both succeed", func(t *testing.T) {
        // ... test logic for this case ...
    })
}

func TestSyncMetadataInternal(t *testing.T) {
mockTotalStorageBytesCommon := func(e *EFCEngine) (int64, error) {
return 0, nil
Expand Down