MCPcopy
hub / github.com/fluid-cloudnative/fluid / TestMutate

Function TestMutate

pkg/webhook/plugins/fusesidecar/fuse_sidecar_test.go:28–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestMutate(t *testing.T) {
29 var (
30 client client.Client
31 pod *corev1.Pod
32 )
33
34 plugin, err := NewPlugin(client, "")
35 if err != nil {
36 t.Error("new plugin occurs error", err)
37 }
38 if plugin.GetName() != Name {
39 t.Errorf("GetName expect %v, got %v", Name, plugin.GetName())
40 }
41
42 runtimeInfo, err := base.BuildRuntimeInfo("test", "fluid", "alluxio")
43 if err != nil {
44 t.Errorf("fail to create the runtimeInfo with error %v", err)
45 }
46
47 pod = &corev1.Pod{
48 ObjectMeta: metav1.ObjectMeta{
49 Name: "test",
50 Namespace: "test",
51 },
52 }
53
54 shouldStop, err := plugin.Mutate(pod, map[string]base.RuntimeInfoInterface{"test": runtimeInfo})
55 if err != nil {
56 t.Errorf("fail to mutate pod with error %v", err)
57 }
58
59 if shouldStop {
60 t.Errorf("expect shouldStop as false, but got %v", shouldStop)
61 }
62
63 _, err = plugin.Mutate(pod, map[string]base.RuntimeInfoInterface{})
64 if err != nil {
65 t.Errorf("fail to mutate pod with error %v", err)
66 }
67
68 _, err = plugin.Mutate(pod, map[string]base.RuntimeInfoInterface{"test": nil})
69 if err != nil {
70 t.Errorf("expect error is nil")
71 }
72}

Callers

nothing calls this directly

Calls 5

BuildRuntimeInfoFunction · 0.92
NewPluginFunction · 0.70
GetNameMethod · 0.65
MutateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected