(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func 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 | } |
nothing calls this directly
no test coverage detected