Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package model |
| 17 | |
| 18 | import ( |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 19 | "encoding/hex" |
| 20 | "encoding/json" |
khenaidoo | b920354 | 2018-09-17 22:56:37 -0400 | [diff] [blame] | 21 | "github.com/google/uuid" |
khenaidoo | b920354 | 2018-09-17 22:56:37 -0400 | [diff] [blame] | 22 | "github.com/opencord/voltha-go/protos/voltha" |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 23 | "github.com/opencord/voltha-go/protos/openflow_13" |
khenaidoo | b920354 | 2018-09-17 22:56:37 -0400 | [diff] [blame] | 24 | "reflect" |
| 25 | "strconv" |
| 26 | "testing" |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 27 | ) |
| 28 | |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 29 | var ( |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 30 | ) |
| 31 | |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 32 | func Test_Proxy_1_1_Add_NewDevice(t *testing.T) { |
| 33 | devIdBin, _ := uuid.New().MarshalBinary() |
| 34 | devId = "0001" + hex.EncodeToString(devIdBin)[:12] |
| 35 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 36 | preAddExecuted := false |
| 37 | postAddExecuted := false |
| 38 | |
| 39 | modelTestConfig.RootProxy.RegisterCallback(PRE_ADD, commonCallback, "PRE_ADD instructions", &preAddExecuted) |
| 40 | modelTestConfig.RootProxy.RegisterCallback(POST_ADD, commonCallback, "POST_ADD instructions", &postAddExecuted) |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 41 | |
| 42 | device.Id = devId |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 43 | if added := modelTestConfig.RootProxy.Add("/devices", device, ""); added == nil { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 44 | t.Error("Failed to add device") |
| 45 | } else { |
| 46 | t.Logf("Added device : %+v", added) |
| 47 | } |
| 48 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 49 | if d := modelTestConfig.RootProxy.Get("/devices/"+devId, 0, false, ""); !reflect.ValueOf(d).IsValid() { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 50 | t.Error("Failed to find added device") |
| 51 | } else { |
| 52 | djson, _ := json.Marshal(d) |
| 53 | t.Logf("Found device: %s", string(djson)) |
| 54 | } |
| 55 | |
| 56 | if !preAddExecuted { |
| 57 | t.Error("PRE_ADD callback was not executed") |
| 58 | } |
| 59 | if !postAddExecuted { |
| 60 | t.Error("POST_ADD callback was not executed") |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func Test_Proxy_1_2_Add_ExistingDevice(t *testing.T) { |
| 65 | device.Id = devId |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 66 | if added := modelTestConfig.RootProxy.Add("/devices", device, ""); added == nil { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 67 | t.Logf("Successfully detected that the device already exists: %s", devId) |
| 68 | } else { |
| 69 | t.Errorf("A new device should not have been created : %+v", added) |
| 70 | } |
| 71 | |
| 72 | } |
| 73 | |
| 74 | func Test_Proxy_2_1_Get_AllDevices(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 75 | devices := modelTestConfig.RootProxy.Get("/devices", 1, false, "") |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 76 | |
| 77 | if len(devices.([]interface{})) == 0 { |
| 78 | t.Error("there are no available devices to retrieve") |
| 79 | } else { |
| 80 | // Save the target device id for later tests |
| 81 | targetDeviceId = devices.([]interface{})[0].(*voltha.Device).Id |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 82 | t.Logf("retrieved all devices: %+v", devices) |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 86 | func Test_Proxy_2_2_Get_SingleDevice(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 87 | if d := modelTestConfig.RootProxy.Get("/devices/"+targetDeviceId, 0, false, ""); !reflect.ValueOf(d).IsValid() { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 88 | t.Errorf("Failed to find device : %s", targetDeviceId) |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 89 | } else { |
| 90 | djson, _ := json.Marshal(d) |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 91 | t.Logf("Found device: %s", string(djson)) |
| 92 | } |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 93 | |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | func Test_Proxy_3_1_Update_Device_WithRootProxy(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 97 | if retrieved := modelTestConfig.RootProxy.Get("/devices/"+targetDeviceId, 1, false, ""); retrieved == nil { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 98 | t.Error("Failed to get device") |
| 99 | } else { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 100 | t.Logf("Found raw device (root proxy): %+v", retrieved) |
| 101 | |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 102 | var fwVersion int |
| 103 | if retrieved.(*voltha.Device).FirmwareVersion == "n/a" { |
| 104 | fwVersion = 0 |
| 105 | } else { |
| 106 | fwVersion, _ = strconv.Atoi(retrieved.(*voltha.Device).FirmwareVersion) |
| 107 | fwVersion += 1 |
| 108 | } |
| 109 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 110 | preUpdateExecuted := false |
| 111 | postUpdateExecuted := false |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 112 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 113 | modelTestConfig.RootProxy.RegisterCallback( |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 114 | PRE_UPDATE, |
| 115 | commonCallback, |
| 116 | "PRE_UPDATE instructions (root proxy)", &preUpdateExecuted, |
| 117 | ) |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 118 | modelTestConfig.RootProxy.RegisterCallback( |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 119 | POST_UPDATE, |
| 120 | commonCallback, |
| 121 | "POST_UPDATE instructions (root proxy)", &postUpdateExecuted, |
| 122 | ) |
| 123 | |
| 124 | //cloned := reflect.ValueOf(retrieved).Elem().Interface().(voltha.Device) |
| 125 | //cloned.FirmwareVersion = strconv.Itoa(fwVersion) |
| 126 | retrieved.(*voltha.Device).FirmwareVersion = strconv.Itoa(fwVersion) |
| 127 | //t.Logf("Before update : %+v", cloned) |
| 128 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 129 | if afterUpdate := modelTestConfig.RootProxy.Update("/devices/"+targetDeviceId, retrieved, false, ""); afterUpdate == nil { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 130 | t.Error("Failed to update device") |
| 131 | } else { |
| 132 | t.Logf("Updated device : %+v", afterUpdate.(Revision).GetData()) |
| 133 | } |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 134 | if d := modelTestConfig.RootProxy.Get("/devices/"+targetDeviceId, 1, false, ""); !reflect.ValueOf(d).IsValid() { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 135 | t.Error("Failed to find updated device (root proxy)") |
| 136 | } else { |
| 137 | djson, _ := json.Marshal(d) |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 138 | |
| 139 | t.Logf("Found device (root proxy): %s raw: %+v", string(djson), d) |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | if !preUpdateExecuted { |
| 143 | t.Error("PRE_UPDATE callback was not executed") |
| 144 | } |
| 145 | if !postUpdateExecuted { |
| 146 | t.Error("POST_UPDATE callback was not executed") |
| 147 | } |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 148 | } |
| 149 | } |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 150 | |
| 151 | func Test_Proxy_3_2_Update_Flow_WithSubProxy(t *testing.T) { |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 152 | // Get a device proxy and update a specific port |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 153 | devflowsProxy := modelTestConfig.Root.GetProxy("/devices/"+devId+"/flows", false) |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 154 | flows := devflowsProxy.Get("/", 0, false, "") |
| 155 | //flows.([]interface{})[0].(*openflow_13.Flows).Items[0].TableId = 2222 |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 156 | //flows.([]interface{})[0].(*openflow_13.Flows).Items[0].TableId = 2244 |
| 157 | flows.(*openflow_13.Flows).Items[0].TableId = 2244 |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 158 | t.Logf("before updated flows: %+v", flows) |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 159 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 160 | //devPortsProxy := modelTestConfig.RootProxy.node.GetProxy("/devices/"+devId+"/ports", false) |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 161 | //port123 := devPortsProxy.Get("/123", 0, false, "") |
| 162 | //t.Logf("got ports: %+v", port123) |
| 163 | //port123.(*voltha.Port).OperStatus = common.OperStatus_DISCOVERED |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 164 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 165 | preUpdateExecuted := false |
| 166 | postUpdateExecuted := false |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 167 | |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 168 | devflowsProxy.RegisterCallback( |
| 169 | PRE_UPDATE, |
| 170 | commonCallback, |
| 171 | "PRE_UPDATE instructions (flows proxy)", &preUpdateExecuted, |
| 172 | ) |
| 173 | devflowsProxy.RegisterCallback( |
| 174 | POST_UPDATE, |
| 175 | commonCallback, |
| 176 | "POST_UPDATE instructions (flows proxy)", &postUpdateExecuted, |
| 177 | ) |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 178 | |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 179 | kvFlows := devflowsProxy.Get("/", 0, false, "") |
| 180 | |
| 181 | if reflect.DeepEqual(flows, kvFlows) { |
| 182 | t.Errorf("Local changes have changed the KV store contents - local:%+v, kv: %+v", flows, kvFlows) |
| 183 | } |
| 184 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 185 | if updated := devflowsProxy.Update("/", flows.(*openflow_13.Flows), false, ""); updated == nil { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 186 | t.Error("Failed to update flow") |
| 187 | } else { |
| 188 | t.Logf("Updated flows : %+v", updated) |
| 189 | } |
| 190 | |
| 191 | if d := devflowsProxy.Get("/", 0, false, ""); d == nil { |
| 192 | t.Error("Failed to find updated flows (flows proxy)") |
| 193 | } else { |
| 194 | djson, _ := json.Marshal(d) |
| 195 | t.Logf("Found flows (flows proxy): %s", string(djson)) |
| 196 | } |
| 197 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 198 | if d := modelTestConfig.RootProxy.Get("/devices/"+devId+"/flows", 0, false, ""); !reflect.ValueOf(d).IsValid() { |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 199 | t.Error("Failed to find updated flows (root proxy)") |
| 200 | } else { |
| 201 | djson, _ := json.Marshal(d) |
| 202 | t.Logf("Found flows (root proxy): %s", string(djson)) |
| 203 | } |
| 204 | |
| 205 | if !preUpdateExecuted { |
| 206 | t.Error("PRE_UPDATE callback was not executed") |
| 207 | } |
| 208 | if !postUpdateExecuted { |
| 209 | t.Error("POST_UPDATE callback was not executed") |
| 210 | } |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 211 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 212 | //Get a device proxy and update all its ports |
| 213 | |
| 214 | |
| 215 | //devProxy := modelTestConfig.RootProxy.GetProxy("/devices/"+devId, false) |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 216 | //ports := devProxy.Get("/ports", 0, false, "") |
| 217 | //t.Logf("got ports: %+v", ports) |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 218 | //devProxy.RegisterCallback(POST_UPDATE, commonCallback, nil) |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 219 | // |
| 220 | //ports.([]interface{})[0].(*voltha.Port).OperStatus = common.OperStatus_DISCOVERED |
| 221 | // |
| 222 | //devProxy.Update("/ports", ports, false, "") |
| 223 | //updated := devProxy.Get("/ports", 0, false, "") |
| 224 | //t.Logf("got updated ports: %+v", updated) |
| 225 | |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 226 | // |
| 227 | // Get a device proxy, retrieve all the ports and update a specific one |
| 228 | // |
| 229 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 230 | //devProxy := modelTestConfig.RootProxy.GetProxy("/devices/"+devId, false) |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 231 | //ports := devProxy.Get("/ports", 0, false, "") |
| 232 | //t.Logf("got ports: %+v", ports) |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 233 | //devProxy.RegisterCallback(POST_UPDATE, commonCallback, nil) |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 234 | // |
| 235 | //ports.([]interface{})[0].(*voltha.Port).OperStatus = common.OperStatus_DISCOVERED |
| 236 | // |
| 237 | //devProxy.Update("/ports/123", ports.([]interface{})[0], false, "") |
| 238 | //updated := devProxy.Get("/ports", 0, false, "") |
| 239 | //t.Logf("got updated ports: %+v", updated) |
| 240 | } |
| 241 | |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 242 | func Test_Proxy_4_1_Remove_Device(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 243 | preRemoveExecuted := false |
| 244 | postRemoveExecuted := false |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 245 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 246 | modelTestConfig.RootProxy.RegisterCallback( |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 247 | PRE_REMOVE, |
| 248 | commonCallback, |
| 249 | "PRE_REMOVE instructions (root proxy)", &preRemoveExecuted, |
| 250 | ) |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 251 | modelTestConfig.RootProxy.RegisterCallback( |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 252 | POST_REMOVE, |
| 253 | commonCallback, |
| 254 | "POST_REMOVE instructions (root proxy)", &postRemoveExecuted, |
| 255 | ) |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 256 | |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 257 | if removed := modelTestConfig.RootProxy.Remove("/devices/"+devId, ""); removed == nil { |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 258 | t.Error("Failed to remove device") |
| 259 | } else { |
| 260 | t.Logf("Removed device : %+v", removed) |
| 261 | } |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 262 | if d := modelTestConfig.RootProxy.Get("/devices/"+devId, 0, false, ""); reflect.ValueOf(d).IsValid() { |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 263 | djson, _ := json.Marshal(d) |
| 264 | t.Errorf("Device was not removed - %s", djson) |
| 265 | } else { |
| 266 | t.Logf("Device was removed: %s", devId) |
| 267 | } |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 268 | |
| 269 | if !preRemoveExecuted { |
| 270 | t.Error("PRE_UPDATE callback was not executed") |
| 271 | } |
| 272 | if !postRemoveExecuted { |
| 273 | t.Error("POST_UPDATE callback was not executed") |
| 274 | } |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 275 | } |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 276 | |
| 277 | // ----------------------------- |
| 278 | // Callback tests |
| 279 | // ----------------------------- |
| 280 | |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 281 | func Test_Proxy_Callbacks_1_Register(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 282 | modelTestConfig.RootProxy.RegisterCallback(PRE_ADD, firstCallback, "abcde", "12345") |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 283 | |
| 284 | m := make(map[string]string) |
| 285 | m["name"] = "fghij" |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 286 | modelTestConfig.RootProxy.RegisterCallback(PRE_ADD, secondCallback, m, 1.2345) |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 287 | |
| 288 | d := &voltha.Device{Id: "12345"} |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 289 | modelTestConfig.RootProxy.RegisterCallback(PRE_ADD, thirdCallback, "klmno", d) |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | func Test_Proxy_Callbacks_2_Invoke_WithNoInterruption(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 293 | modelTestConfig.RootProxy.InvokeCallbacks(PRE_ADD, false, nil) |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 294 | } |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 295 | |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 296 | func Test_Proxy_Callbacks_3_Invoke_WithInterruption(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 297 | modelTestConfig.RootProxy.InvokeCallbacks(PRE_ADD, true, nil) |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | func Test_Proxy_Callbacks_4_Unregister(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 301 | modelTestConfig.RootProxy.UnregisterCallback(PRE_ADD, firstCallback) |
| 302 | modelTestConfig.RootProxy.UnregisterCallback(PRE_ADD, secondCallback) |
| 303 | modelTestConfig.RootProxy.UnregisterCallback(PRE_ADD, thirdCallback) |
Stephane Barbarie | 694e2b9 | 2018-09-07 12:17:36 -0400 | [diff] [blame] | 304 | } |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 305 | |
| 306 | //func Test_Proxy_Callbacks_5_Add(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 307 | // modelTestConfig.RootProxy.Root.AddCallback(modelTestConfig.RootProxy.InvokeCallbacks, POST_UPDATE, false, "some data", "some new data") |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 308 | //} |
| 309 | // |
| 310 | //func Test_Proxy_Callbacks_6_Execute(t *testing.T) { |
Stephane Barbarie | a188d94 | 2018-10-16 16:43:04 -0400 | [diff] [blame] | 311 | // modelTestConfig.RootProxy.Root.ExecuteCallbacks() |
Stephane Barbarie | 126101e | 2018-10-11 16:18:48 -0400 | [diff] [blame] | 312 | //} |