summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-07-23 13:20:40 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-08-03 13:54:38 -0400
commit0286d59c82657abe96ccaa3eebea7240ac30ca81 (patch)
tree2a8cac480013be55cfb42c6d47b4828059b78532 /src/tests
parent34e93359de515da5e75bb34f9f7569f1715f0aa0 (diff)
downloadsssd-0286d59c82657abe96ccaa3eebea7240ac30ca81.tar.gz
sssd-0286d59c82657abe96ccaa3eebea7240ac30ca81.tar.xz
sssd-0286d59c82657abe96ccaa3eebea7240ac30ca81.zip
Add sysdb_attrs_to_list() utility function
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/sysdb-tests.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 44cb6dc3e..ee1795033 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -2076,6 +2076,35 @@ START_TEST (test_sysdb_memberof_check_memberuid_loop_without_group_5)
}
END_TEST
+START_TEST (test_sysdb_attrs_to_list)
+{
+ struct sysdb_attrs *attrs_list[3];
+ char **list;
+ errno_t ret;
+
+ TALLOC_CTX *test_ctx = talloc_new(NULL);
+
+ attrs_list[0] = sysdb_new_attrs(test_ctx);
+ sysdb_attrs_add_string(attrs_list[0], "test_attr", "attr1");
+ attrs_list[1] = sysdb_new_attrs(test_ctx);
+ sysdb_attrs_add_string(attrs_list[1], "test_attr", "attr2");
+ attrs_list[2] = sysdb_new_attrs(test_ctx);
+ sysdb_attrs_add_string(attrs_list[2], "nottest_attr", "attr3");
+
+ ret = sysdb_attrs_to_list(test_ctx, attrs_list, 3,
+ "test_attr", &list);
+ fail_unless(ret == EOK, "sysdb_attrs_to_list failed with code %d", ret);
+
+ fail_unless(strcmp(list[0],"attr1") == 0, "Expected [attr1], got [%s]",
+ list[0]);
+ fail_unless(strcmp(list[1],"attr2") == 0, "Expected [attr2], got [%s]",
+ list[1]);
+ fail_unless(list[2] == NULL, "List should be NULL-terminated");
+
+ talloc_free(test_ctx);
+}
+END_TEST
+
Suite *create_sysdb_suite(void)
{
Suite *s = suite_create("sysdb");
@@ -2185,6 +2214,8 @@ Suite *create_sysdb_suite(void)
tcase_add_test(tc_sysdb, test_sysdb_attrs_replace_name);
+ tcase_add_test(tc_sysdb, test_sysdb_attrs_to_list);
+
/* Add all test cases to the test suite */
suite_add_tcase(s, tc_sysdb);