Skip to content

Commit 12e5a5e

Browse files
authored
test(ddc/goosefs): migrate engine tests to ginkgo (#5560)
Signed-off-by: Harsh <harshmastic@gmail.com>
1 parent efbde02 commit 12e5a5e

1 file changed

Lines changed: 57 additions & 56 deletions

File tree

pkg/ddc/goosefs/engine_test.go

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ 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
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
2324
"github.com/fluid-cloudnative/fluid/pkg/common"
@@ -30,65 +31,65 @@ import (
3031
"k8s.io/apimachinery/pkg/types"
3132
)
3233

33-
func TestBuild(t *testing.T) {
34-
var namespace = v1.Namespace{
35-
ObjectMeta: metav1.ObjectMeta{
36-
Name: "fluid",
37-
},
38-
}
39-
testObjs := []runtime.Object{}
40-
testObjs = append(testObjs, namespace.DeepCopy())
34+
var _ = Describe("Build", func() {
35+
It("should build engine successfully", func() {
36+
var namespace = v1.Namespace{
37+
ObjectMeta: metav1.ObjectMeta{
38+
Name: "fluid",
39+
},
40+
}
41+
testObjs := []runtime.Object{}
42+
testObjs = append(testObjs, namespace.DeepCopy())
4143

42-
var dataset = datav1alpha1.Dataset{
43-
ObjectMeta: metav1.ObjectMeta{
44-
Name: "hbase",
45-
Namespace: "fluid",
46-
},
47-
}
48-
testObjs = append(testObjs, dataset.DeepCopy())
44+
var dataset = datav1alpha1.Dataset{
45+
ObjectMeta: metav1.ObjectMeta{
46+
Name: "hbase",
47+
Namespace: "fluid",
48+
},
49+
}
50+
testObjs = append(testObjs, dataset.DeepCopy())
4951

50-
var runtime = datav1alpha1.GooseFSRuntime{
51-
ObjectMeta: metav1.ObjectMeta{
52-
Name: "hbase",
53-
Namespace: "fluid",
54-
},
55-
Spec: datav1alpha1.GooseFSRuntimeSpec{
56-
Master: datav1alpha1.GooseFSCompTemplateSpec{
57-
Replicas: 1,
52+
var goosefsRuntime = datav1alpha1.GooseFSRuntime{
53+
ObjectMeta: metav1.ObjectMeta{
54+
Name: "hbase",
55+
Namespace: "fluid",
5856
},
59-
Fuse: datav1alpha1.GooseFSFuseSpec{},
60-
},
61-
Status: datav1alpha1.RuntimeStatus{
62-
CacheStates: map[common.CacheStateName]string{
63-
common.Cached: "true",
57+
Spec: datav1alpha1.GooseFSRuntimeSpec{
58+
Master: datav1alpha1.GooseFSCompTemplateSpec{
59+
Replicas: 1,
60+
},
61+
Fuse: datav1alpha1.GooseFSFuseSpec{},
6462
},
65-
},
66-
}
67-
testObjs = append(testObjs, runtime.DeepCopy())
68-
69-
var daemonset = appsv1.DaemonSet{
70-
ObjectMeta: metav1.ObjectMeta{
71-
Name: "hbase-worker",
72-
Namespace: "fluid",
73-
},
74-
}
75-
testObjs = append(testObjs, daemonset.DeepCopy())
76-
client := fake.NewFakeClientWithScheme(testScheme, testObjs...)
63+
Status: datav1alpha1.RuntimeStatus{
64+
CacheStates: map[common.CacheStateName]string{
65+
common.Cached: "true",
66+
},
67+
},
68+
}
69+
testObjs = append(testObjs, goosefsRuntime.DeepCopy())
7770

78-
var ctx = cruntime.ReconcileRequestContext{
79-
NamespacedName: types.NamespacedName{
80-
Name: "hbase",
81-
Namespace: "fluid",
82-
},
83-
Client: client,
84-
Log: fake.NullLogger(),
85-
RuntimeType: "goosefs",
86-
Runtime: &runtime,
87-
}
71+
var daemonset = appsv1.DaemonSet{
72+
ObjectMeta: metav1.ObjectMeta{
73+
Name: "hbase-worker",
74+
Namespace: "fluid",
75+
},
76+
}
77+
testObjs = append(testObjs, daemonset.DeepCopy())
78+
client := fake.NewFakeClientWithScheme(testScheme, testObjs...)
8879

89-
engine, err := Build("testId", ctx)
90-
if err != nil || engine == nil {
91-
t.Errorf("fail to exec the build function with the eror %v", err)
92-
}
80+
var ctx = cruntime.ReconcileRequestContext{
81+
NamespacedName: types.NamespacedName{
82+
Name: "hbase",
83+
Namespace: "fluid",
84+
},
85+
Client: client,
86+
Log: fake.NullLogger(),
87+
RuntimeType: "goosefs",
88+
Runtime: &goosefsRuntime,
89+
}
9390

94-
}
91+
engine, err := Build("testId", ctx)
92+
Expect(err).NotTo(HaveOccurred())
93+
Expect(engine).NotTo(BeNil())
94+
})
95+
})

0 commit comments

Comments
 (0)