From 66a95ec04677991c2ad875b0d1e9de6dd4d5ab53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Mon, 26 Jan 2015 15:28:50 +0100
Subject: [PATCH 02/12] cache_req tests: define user name constant

Using a constant here is better since the name is shared between
the test function and testing _done function.
---
 src/tests/cmocka/test_responder_cache_req.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/tests/cmocka/test_responder_cache_req.c b/src/tests/cmocka/test_responder_cache_req.c
index 6c83cac0fb9bee6ebe767b5cca14622cce2db23c..bc551f8a3518aa777febd19cfe3947868a19b39c 100644
--- a/src/tests/cmocka/test_responder_cache_req.c
+++ b/src/tests/cmocka/test_responder_cache_req.c
@@ -33,6 +33,8 @@
 #define TEST_DOM_NAME "responder_cache_req_test"
 #define TEST_ID_PROVIDER "ldap"
 
+#define TEST_USER_NAME "test-user"
+
 #define new_single_domain_test(test) \
     unit_test_setup_teardown(test_ ## test, \
                              test_single_domain_setup, \
@@ -86,9 +88,10 @@ __wrap_sss_dp_get_account_send(TALLOC_CTX *mem_ctx,
     ctx->dp_called = true;
 
     if (ctx->create_user) {
-        ret = sysdb_store_user(ctx->tctx->dom, "test-user", "pwd", 1000, 1000,
-                               NULL, NULL, NULL, "cn=test-user,dc=test", NULL,
-                               NULL, 1000, time(NULL));
+        ret = sysdb_store_user(ctx->tctx->dom, TEST_USER_NAME, "pwd",
+                               1000, 1000, NULL, NULL, NULL,
+                               "cn=test-user,dc=test", NULL, NULL,
+                               1000, time(NULL));
         assert_int_equal(ret, EOK);
     }
 
@@ -173,7 +176,7 @@ void test_user_by_name_multiple_domains_found(void **state)
     struct sss_domain_info *domain = NULL;
     TALLOC_CTX *req_mem_ctx = NULL;
     struct tevent_req *req = NULL;
-    const char *name = "test-user";
+    const char *name = TEST_USER_NAME;
     const char *ldbname = NULL;
     errno_t ret;
 
@@ -225,7 +228,7 @@ void test_user_by_name_multiple_domains_notfound(void **state)
     struct cache_req_test_ctx *test_ctx = NULL;
     TALLOC_CTX *req_mem_ctx = NULL;
     struct tevent_req *req = NULL;
-    const char *name = "test-user";
+    const char *name = TEST_USER_NAME;
     errno_t ret;
 
     test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
@@ -254,7 +257,7 @@ void test_user_by_name_cache_valid(void **state)
     struct cache_req_test_ctx *test_ctx = NULL;
     TALLOC_CTX *req_mem_ctx = NULL;
     struct tevent_req *req = NULL;
-    const char *name = "test-user";
+    const char *name = TEST_USER_NAME;
     const char *ldbname = NULL;
     errno_t ret;
 
@@ -294,7 +297,7 @@ void test_user_by_name_cache_expired(void **state)
     struct cache_req_test_ctx *test_ctx = NULL;
     TALLOC_CTX *req_mem_ctx = NULL;
     struct tevent_req *req = NULL;
-    const char *name = "test-user";
+    const char *name = TEST_USER_NAME;
     const char *ldbname = NULL;
     errno_t ret;
 
@@ -340,7 +343,7 @@ void test_user_by_name_cache_midpoint(void **state)
     struct cache_req_test_ctx *test_ctx = NULL;
     TALLOC_CTX *req_mem_ctx = NULL;
     struct tevent_req *req = NULL;
-    const char *name = "test-user";
+    const char *name = TEST_USER_NAME;
     const char *ldbname = NULL;
     errno_t ret;
 
@@ -385,7 +388,7 @@ void test_user_by_name_ncache(void **state)
     struct cache_req_test_ctx *test_ctx = NULL;
     TALLOC_CTX *req_mem_ctx = NULL;
     struct tevent_req *req = NULL;
-    const char *name = "test-user";
+    const char *name = TEST_USER_NAME;
     errno_t ret;
 
     test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
@@ -415,7 +418,7 @@ void test_user_by_name_missing_found(void **state)
     struct cache_req_test_ctx *test_ctx = NULL;
     TALLOC_CTX *req_mem_ctx = NULL;
     struct tevent_req *req = NULL;
-    const char *name = "test-user";
+    const char *name = TEST_USER_NAME;
     const char *ldbname = NULL;
     errno_t ret;
 
@@ -457,7 +460,7 @@ void test_user_by_name_missing_notfound(void **state)
     struct cache_req_test_ctx *test_ctx = NULL;
     TALLOC_CTX *req_mem_ctx = NULL;
     struct tevent_req *req = NULL;
-    const char *name = "test-user";
+    const char *name = TEST_USER_NAME;
     errno_t ret;
 
     test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
-- 
2.1.0

