Skip to content

Commit 71ad99b

Browse files
Syspretor玖宇
andauthored
add gofmt verify in github ci workflow (#4799)
Signed-off-by: 玖宇 <guotongyu.gty@alibaba-inc.com> Co-authored-by: 玖宇 <guotongyu.gty@alibaba-inc.com>
1 parent 8c42562 commit 71ad99b

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

.github/workflows/project-check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ jobs:
6262
echo $(git status --porcelain | grep generated)
6363
if [ -z "$(git status --porcelain | grep generated)" ]; then echo "openapi validation passed."; else echo "openapi validation failed. Please use 'make gen-openapi' to update openapi"; exit 1; fi
6464
65+
- name: Code fmt check
66+
run: |
67+
gofmt -l ./pkg ./cmd ./api | grep . && echo "Please run "make fmt" to verify gofmt" && exit 1 || exit 0
6568
6669
- name: Project lint
6770
run: |

pkg/ddc/alluxio/master_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ func TestShouldSetupMaster(t *testing.T) {
242242
// It initializes a fake Kubernetes client with predefined StatefulSet and AlluxioRuntime objects,
243243
// then verifies whether SetupMaster correctly updates the runtime's status fields.
244244
// The test ensures that:
245-
// 1. The SetupMaster function executes without errors.
246-
// 2. The runtime object is correctly retrieved after execution.
247-
// 3. The runtime's status is properly updated, including the selector,
248-
// configuration map name, and the presence of conditions.。
245+
// 1. The SetupMaster function executes without errors.
246+
// 2. The runtime object is correctly retrieved after execution.
247+
// 3. The runtime's status is properly updated, including the selector,
248+
// configuration map name, and the presence of conditions.。
249249
func TestSetupMaster(t *testing.T) {
250250
statefulSetInputs := []v1.StatefulSet{
251251
{

pkg/ddc/alluxio/transform_resources_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,23 +380,24 @@ func TestTransformResourcesForWorkerWithValue(t *testing.T) {
380380
}
381381
}
382382

383-
// TestTransformResourcesForWorkerWithOnlyRequest is a unit test function that validates the transformation
384-
// of resource requests for Alluxio workers when only resource requests are specified (without limits).
385-
// This function ensures that the memory and CPU requests are correctly applied to the worker configuration
383+
// TestTransformResourcesForWorkerWithOnlyRequest is a unit test function that validates the transformation
384+
// of resource requests for Alluxio workers when only resource requests are specified (without limits).
385+
// This function ensures that the memory and CPU requests are correctly applied to the worker configuration
386386
// based on the provided resource requests and tiered store settings.
387387
//
388388
// Parameters:
389389
// - t (testing.T): The testing framework used to run the unit test.
390390
//
391391
// Returns:
392-
// - None: The function does not return a value but will report errors if the transformation logic does not
393-
// produce the expected results.
392+
// - None: The function does not return a value but will report errors if the transformation logic does not
393+
// produce the expected results.
394394
//
395395
// This test function performs the following steps:
396396
// 1. Defines resource requests for memory (1Gi) and CPU (500m) with no resource limits.
397397
// 2. Sets up test cases to validate the transformation logic for two scenarios:
398-
// - Scenario 1: A tiered store configuration is provided with a memory quota of 20Gi.
399-
// - Scenario 2: No tiered store configuration is provided, and the memory request remains as 1Gi.
398+
// - Scenario 1: A tiered store configuration is provided with a memory quota of 20Gi.
399+
// - Scenario 2: No tiered store configuration is provided, and the memory request remains as 1Gi.
400+
//
400401
// 3. Initializes an AlluxioEngine instance with a fake client and runtime objects for testing.
401402
// 4. Transforms the resource requirements for the worker using the AlluxioEngine.
402403
// 5. Validates that the transformed memory requests match the expected values based on the scenarios.

pkg/ddc/alluxio/utils_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func TestGetRuntime(t *testing.T) {
424424
}
425425

426426
// TestGetMasterPod verifies the correct retrieval of the master Pod for an Alluxio runtime.
427-
// This test validates whether the AlluxioEngine's getMasterPod method accurately fetches
427+
// This test validates whether the AlluxioEngine's getMasterPod method accurately fetches
428428
// the expected Pod resource from Kubernetes based on the provided runtime configuration.
429429
//
430430
// Test Cases:
@@ -736,14 +736,14 @@ func TestGetWorkerDaemonsetName(t *testing.T) {
736736
}
737737

738738
// TestGetFuseDaemonsetName is a unit test for the getFuseName method of the AlluxioEngine struct.
739-
// This test verifies that the method correctly constructs the expected daemonset name
739+
// This test verifies that the method correctly constructs the expected daemonset name
740740
// based on the given engine name.
741-
// The test defines a struct `fields` containing the engine name and a test case struct
741+
// The test defines a struct `fields` containing the engine name and a test case struct
742742
// that includes the test case name, input fields, and the expected daemonset name.
743743
// The test case used:
744744
// - When the engine name is "spark", the expected daemonset name should be "spark-fuse".
745-
// The test iterates through all defined cases, creates an instance of AlluxioEngine with
746-
// the given name, calls the `getFuseName` method, and checks if the returned result matches
745+
// The test iterates through all defined cases, creates an instance of AlluxioEngine with
746+
// the given name, calls the `getFuseName` method, and checks if the returned result matches
747747
// the expected value. If the result differs, an error message is reported.
748748
func TestGetFuseDaemonsetName(t *testing.T) {
749749
type fields struct {

pkg/ddc/jindo/dataset_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ func TestUpdateCacheOfDataset(t *testing.T) {
123123
// 3. Proper synchronization of cache states from runtime status
124124
//
125125
// Test strategy:
126-
// - Creates mock Dataset and JindoRuntime objects in a test namespace
127-
// - Uses a fake Kubernetes client to simulate API server interactions
128-
// - Verifies three key aspects of DatasetStatus after updates:
129-
// a) Phase matches expected state
130-
// b) CacheStates are properly propagated from runtime status
131-
// c) HCFSStatus fields remain unchanged during phase transitions
126+
// - Creates mock Dataset and JindoRuntime objects in a test namespace
127+
// - Uses a fake Kubernetes client to simulate API server interactions
128+
// - Verifies three key aspects of DatasetStatus after updates:
129+
// a) Phase matches expected state
130+
// b) CacheStates are properly propagated from runtime status
131+
// c) HCFSStatus fields remain unchanged during phase transitions
132132
//
133133
// Test cases cover:
134134
// - Successful bound state update

0 commit comments

Comments
 (0)