MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / test_cachedb_url

Function test_cachedb_url

cachedb/test/test_cachedb.c:689–943  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687
688
689static void test_cachedb_url(void)
690{
691#define CDB_PARSE(__url) db = new_cachedb_id(_str(__url)); if (!ok(db != NULL)) return;
692 struct cachedb_id *db;
693
694 /* invalid URLs */
695 ok(!new_cachedb_id(_str("d:g://@")));
696 ok(!new_cachedb_id(_str("d:g://u:@")));
697 ok(!new_cachedb_id(_str("d:g://u:p")));
698 ok(!new_cachedb_id(_str("d:g://u:p@")));
699 ok(!new_cachedb_id(_str("d:g://u:p@h:")));
700
701 CDB_PARSE("redis:group1://");
702 ok(db->flags == CACHEDB_ID_NO_URL);
703 ok(!strcmp(db->scheme, "redis"));
704 ok(!strcmp(db->group_name, "group1"));
705 ok(!db->username);
706 ok(!db->password);
707 ok(!db->host);
708 ok(db->port == 0);
709 ok(!db->database);
710 ok(!db->extra_options);
711
712 CDB_PARSE("redis:group1://172.31.180.127");
713 ok(db->flags == 0);
714 ok(!strcmp(db->scheme, "redis"));
715 ok(!strcmp(db->group_name, "group1"));
716 ok(!db->username);
717 ok(!db->password);
718 ok(!strcmp(db->host, "172.31.180.127"));
719 ok(db->port == 0);
720 ok(!db->database);
721 ok(!db->extra_options);
722
723 CDB_PARSE("redis:group1://172.31.180.127:6379");
724 ok(db->flags == 0);
725 ok(!strcmp(db->scheme, "redis"));
726 ok(!strcmp(db->group_name, "group1"));
727 ok(!db->username);
728 ok(!db->password);
729 ok(!strcmp(db->host, "172.31.180.127"));
730 ok(db->port == 6379);
731 ok(!db->database);
732 ok(!db->extra_options);
733
734 CDB_PARSE("redis:group1://user@172.31.180.127:6379");
735 ok(db->flags == 0);
736 ok(!strcmp(db->username, "user"));
737 ok(!db->password);
738 ok(!strcmp(db->host, "172.31.180.127"));
739 ok(db->port == 6379);
740 ok(!db->database);
741 ok(!db->extra_options);
742
743 CDB_PARSE("redis:group1://:pwd@172.31.180.127:6379");
744 ok(db->flags == 0);
745 ok(!strcmp(db->scheme, "redis"));
746 ok(!strcmp(db->group_name, "group1"));

Callers 1

test_cachedbFunction · 0.85

Calls 2

new_cachedb_idFunction · 0.85
_strClass · 0.85

Tested by

no test coverage detected