Skip to content

Commit efbde02

Browse files
authored
test(ddc/goosefs): migrate sync_runtime tests to ginkgo (v2) (#5559)
* test(ddc/goosefs): migrate sync_runtime tests to ginkgo Signed-off-by: Harsh <harshmastic@gmail.com> * refactor: remove redundant name field Signed-off-by: Harsh <harshmastic@gmail.com> --------- Signed-off-by: Harsh <harshmastic@gmail.com>
1 parent 497bb7e commit efbde02

1 file changed

Lines changed: 25 additions & 61 deletions

File tree

pkg/ddc/goosefs/sync_runtime_test.go

Lines changed: 25 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,72 +17,36 @@ limitations under the License.
1717
package goosefs
1818

1919
import (
20-
"testing"
20+
. "github.com/onsi/ginkgo/v2"
21+
. "github.com/onsi/gomega"
2122

2223
cruntime "github.com/fluid-cloudnative/fluid/pkg/runtime"
2324
)
2425

25-
func TestGooseFSEngine_SyncRuntime(t *testing.T) {
26-
type fields struct {
27-
// runtime *datav1alpha1.GooseFSRuntime
28-
// name string
29-
// namespace string
30-
// runtimeType string
31-
// Log logr.Logger
32-
// Client client.Client
33-
// gracefulShutdownLimits int32
34-
// retryShutdown int32
35-
// initImage string
36-
// MetadataSyncDoneCh chan MetadataSyncResult
37-
// runtimeInfo base.RuntimeInfoInterface
38-
// UnitTest bool
39-
// lastCacheHitStates *cacheHitStates
40-
// Helper *ctrl.Helper
41-
// Recorder record.EventRecorder
42-
}
43-
type args struct {
44-
ctx cruntime.ReconcileRequestContext
45-
}
46-
tests := []struct {
47-
name string
48-
fields fields
49-
args args
26+
var _ = Describe("GooseFSEngine_SyncRuntime", func() {
27+
type testCase struct {
28+
ctx cruntime.ReconcileRequestContext
5029
wantChanged bool
5130
wantErr bool
52-
}{
53-
{
54-
name: "default",
55-
wantChanged: false,
56-
wantErr: false,
57-
},
5831
}
59-
for _, tt := range tests {
60-
t.Run(tt.name, func(t *testing.T) {
61-
e := &GooseFSEngine{
62-
// runtime: tt.fields.runtime,
63-
// name: tt.fields.name,
64-
// namespace: tt.fields.namespace,
65-
// runtimeType: tt.fields.runtimeType,
66-
// Log: tt.fields.Log,
67-
// Client: tt.fields.Client,
68-
// gracefulShutdownLimits: tt.fields.gracefulShutdownLimits,
69-
// retryShutdown: tt.fields.retryShutdown,
70-
// initImage: tt.fields.initImage,
71-
// MetadataSyncDoneCh: tt.fields.MetadataSyncDoneCh,
72-
// runtimeInfo: tt.fields.runtimeInfo,
73-
// UnitTest: tt.fields.UnitTest,
74-
// lastCacheHitStates: tt.fields.lastCacheHitStates,
75-
// Helper: tt.fields.Helper,
76-
// Recorder: tt.fields.Recorder,
77-
}
78-
gotChanged, err := e.SyncRuntime(tt.args.ctx)
79-
if (err != nil) != tt.wantErr {
80-
t.Errorf("GooseFSEngine.SyncRuntime() error = %v, wantErr %v", err, tt.wantErr)
81-
return
82-
}
83-
if gotChanged != tt.wantChanged {
84-
t.Errorf("GooseFSEngine.SyncRuntime() = %v, want %v", gotChanged, tt.wantChanged)
32+
33+
DescribeTable("should sync runtime correctly",
34+
func(tc testCase) {
35+
e := &GooseFSEngine{}
36+
gotChanged, err := e.SyncRuntime(tc.ctx)
37+
38+
if tc.wantErr {
39+
Expect(err).To(HaveOccurred())
40+
} else {
41+
Expect(err).NotTo(HaveOccurred())
8542
}
86-
})
87-
}
88-
}
43+
Expect(gotChanged).To(Equal(tc.wantChanged))
44+
},
45+
Entry("default case",
46+
testCase{
47+
wantChanged: false,
48+
wantErr: false,
49+
},
50+
),
51+
)
52+
})

0 commit comments

Comments
 (0)