Test helper for SYS-REQ-010.
(t *testing.T, testKind string, tests []DeleteTest, runner func(DeleteTest) (interface{}, []byte), resultChecker func(DeleteTest, interface{}) (bool, interface{}))
| 1297 | |
| 1298 | // Test helper for SYS-REQ-010. |
| 1299 | func runDeleteTests(t *testing.T, testKind string, tests []DeleteTest, runner func(DeleteTest) (interface{}, []byte), resultChecker func(DeleteTest, interface{}) (bool, interface{})) { |
| 1300 | for _, test := range tests { |
| 1301 | if activeTest != "" && test.desc != activeTest { |
| 1302 | continue |
| 1303 | } |
| 1304 | |
| 1305 | original := make([]byte, len(test.json)) |
| 1306 | copy(original, test.json) |
| 1307 | |
| 1308 | fmt.Println("Running:", test.desc) |
| 1309 | |
| 1310 | value, bytes := runner(test) |
| 1311 | |
| 1312 | if string(original) != string(bytes) { |
| 1313 | t.Errorf("ORIGINAL DATA MALFORMED: %v, %v", string(original), string(bytes)) |
| 1314 | continue |
| 1315 | } |
| 1316 | |
| 1317 | if test.data == nil { |
| 1318 | t.Errorf("MALFORMED TEST: %v", test) |
| 1319 | continue |
| 1320 | } |
| 1321 | |
| 1322 | if ok, expected := resultChecker(test, value); !ok { |
| 1323 | if expectedBytes, ok := expected.([]byte); ok { |
| 1324 | expected = string(expectedBytes) |
| 1325 | } |
| 1326 | if valueBytes, ok := value.([]byte); ok { |
| 1327 | value = string(valueBytes) |
| 1328 | } |
| 1329 | t.Errorf("%s test '%s' expected to return value %v, but did returned %v instead", testKind, test.desc, expected, value) |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | // Verifies: SYS-REQ-010 [example] |
| 1335 | // MCDC SYS-REQ-010: delete_path_is_provided=F, delete_returns_empty_document_without_path=T => TRUE |
no outgoing calls
no test coverage detected
searching dependent graphs…