Skip to content

Commit

Permalink
* NEW [test] tests for rest api put
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann0222 <yukang.wei@emqx.io>
  • Loading branch information
OdyWayne committed Nov 7, 2023
1 parent 3533598 commit d23a084
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions nanomq/tests/http_server_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ static bool
test_put_rule_sqlite()
{
char *cmd = "curl -i --basic -u admin_test:pw_test -XPUT "
"'http://localhost:8081/api/v4/rules/rule:5' "
"'http://localhost:8081/api/v4/rules/rule:4' "
"-d '{\"rawsql\":\"select * from \\\"t/b\\\"\","
"\"actions\": [{\"name\": \"sqlite\","
"\"params\": {\"table\": \"table_sqlite\"}}],"
Expand All @@ -544,12 +544,27 @@ test_put_rule_sqlite()
return rv;
}

static bool
test_put_rule_mysql()
{
char *cmd = "curl -i --basic -u admin_test:pw_test -XPUT "
"'http://localhost:8081/api/v4/rules/rule:2' "
"-d '{\"rawsql\":\"select * from \\\"t/b\\\"\","
"\"actions\": [{\"name\": \"mysql\","
"\"params\": {\"table\": \"table_mysql\"}}],"
"\"description\": \"mysql-rule\"}'";
FILE *fd = popen(cmd, "r");
bool rv = check_http_return(fd, STATUS_CODE_OK, SUCCEED);
pclose(fd);
return rv;
}

static bool
test_put_rule()
{
assert(test_put_rule_repub());
// assert(test_put_rule_sqlite());
// TODO: put_rule_mysql() & check rule type to update
assert(test_put_rule_sqlite());
assert(test_put_rule_mysql());
return true;
}

Expand Down

0 comments on commit d23a084

Please sign in to comment.