diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-05-27 17:51:25 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-05-27 17:51:25 +0200 |
commit | 4625003149d02227f981b53101c7e6be12226382 (patch) | |
tree | ac1a86f48c69d4da0ec14adc4860f0be7ab422ec /tests/network/protocol/negotiation.c | |
parent | 16b20526e1580f50b29f0dae87a30ebefe0a3c89 (diff) | |
download | libgit2-cmn/server.tar.gz |
server: handle negotiation linescmn/server
A bit of scaffolding for handling the lines from the client telling us
about its commits.
Diffstat (limited to 'tests/network/protocol/negotiation.c')
-rw-r--r-- | tests/network/protocol/negotiation.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/network/protocol/negotiation.c b/tests/network/protocol/negotiation.c new file mode 100644 index 000000000..0fa76a257 --- /dev/null +++ b/tests/network/protocol/negotiation.c @@ -0,0 +1,40 @@ +#include "clar_libgit2.h" +#include "transports/smart.h" + +static git_pkt *pkt; + +void test_network_protocol_negotiation__cleanup(void) +{ + git_pkt_free(pkt); + pkt = NULL; +} + +void test_network_protocol_negotiation__have(void) +{ + const char buf[] = "0032have 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n"; + const char *rest; + git_oid id; + git_pkt_have_want *ppkt; + + git_oid_fromstr(&id, "7e47fe2bd8d01d481f44d7af0531bd93d3b21c01"); + + cl_git_pass(git_pkt_parse_line(&pkt, buf, &rest, sizeof(buf))); + cl_assert_equal_i(GIT_PKT_HAVE, pkt->type); + ppkt = (git_pkt_have_want *) pkt; + cl_assert(!git_oid_cmp(&id, &ppkt->id)); +} + +void test_network_protocol_negotiation__want(void) +{ + const char buf[] = "0032want 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n"; + const char *rest; + git_oid id; + git_pkt_have_want *ppkt; + + git_oid_fromstr(&id, "7e47fe2bd8d01d481f44d7af0531bd93d3b21c01"); + + cl_git_pass(git_pkt_parse_line(&pkt, buf, &rest, sizeof(buf))); + cl_assert_equal_i(GIT_PKT_WANT, pkt->type); + ppkt = (git_pkt_have_want *) pkt; + cl_assert(!git_oid_cmp(&id, &ppkt->id)); +} |