static void test_nc_rpc_commit(void **state) { (void)state; struct nc_rpc *rpc = NULL; /* create commit rpc with NC_PARAMTYPE_CONST*/ rpc = nc_rpc_commit(1, 100, "persist", "persist-id", NC_PARAMTYPE_CONST); assert_non_null(rpc); check_commit_rpc(rpc, 1, 100, "persist", "persist-id"); nc_rpc_free(rpc); /* create commit rpc with NC_PARAMTYPE_FREE*/ char *str1 = strdup("str1"); char *str2 = strdup("str2"); rpc = nc_rpc_commit(2, 5, str1, str2, NC_PARAMTYPE_FREE); assert_non_null(rpc); check_commit_rpc(rpc, 2, 5, str1, str2); nc_rpc_free(rpc); /* create commit rpc with NC_PARAMTYPE_DUP_AND_FREE*/ rpc = nc_rpc_commit(10, 200, "persistent", "persistent-id", NC_PARAMTYPE_DUP_AND_FREE); assert_non_null(rpc); check_commit_rpc(rpc, 10, 200, "persistent", "persistent-id"); nc_rpc_free(rpc); }
static PyObject *ncOpCommit(ncSessionObject *self) { nc_rpc *rpc = NULL; SESSION_CHECK(self); /* create RPC */ rpc = nc_rpc_commit(); if (!rpc) { PyErr_SetString(PyExc_ValueError, "Couldn't create rpc message."); return (NULL); } if (op_send_recv(self, rpc, NULL) == EXIT_SUCCESS) { /* ... and return the result */ Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } }