]>
Commit | Line | Data |
---|---|---|
3a2626f3 CMN |
1 | #include "clay_libgit2.h" |
2 | ||
3 | #define REPOSITORY_FOLDER "testrepo.git" | |
4 | ||
5 | static git_remote *remote; | |
6 | static git_repository *repo; | |
7 | static git_config *cfg; | |
8 | static const git_refspec *refspec; | |
9 | ||
10 | void test_network_remotes__initialize(void) | |
11 | { | |
12 | cl_fixture_sandbox(REPOSITORY_FOLDER); | |
13 | cl_git_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); | |
14 | cl_git_pass(git_repository_config(&cfg, repo, NULL, NULL)); | |
15 | cl_git_pass(git_remote_get(&remote, cfg, "test")); | |
16 | refspec = git_remote_fetchspec(remote); | |
17 | cl_assert(refspec != NULL); | |
18 | } | |
19 | ||
20 | void test_network_remotes__cleanup(void) | |
21 | { | |
22 | git_config_free(cfg); | |
23 | git_repository_free(repo); | |
24 | git_remote_free(remote); | |
25 | } | |
26 | ||
27 | void test_network_remotes__parsing(void) | |
28 | { | |
29 | cl_assert(!strcmp(git_remote_name(remote), "test")); | |
30 | cl_assert(!strcmp(git_remote_url(remote), "git://github.com/libgit2/libgit2")); | |
31 | } | |
32 | ||
33 | void test_network_remotes__refspec_parsing(void) | |
34 | { | |
35 | cl_assert(!strcmp(git_refspec_src(refspec), "refs/heads/*")); | |
36 | cl_assert(!strcmp(git_refspec_dst(refspec), "refs/remotes/test/*")); | |
37 | } | |
38 | ||
39 | void test_network_remotes__fnmatch(void) | |
40 | { | |
41 | cl_git_pass(git_refspec_src_match(refspec, "refs/heads/master")); | |
42 | cl_git_pass(git_refspec_src_match(refspec, "refs/heads/multi/level/branch")); | |
43 | } | |
44 | ||
45 | void test_network_remotes__transform(void) | |
46 | { | |
47 | char ref[1024]; | |
48 | ||
49 | memset(ref, 0x0, sizeof(ref)); | |
50 | cl_git_pass(git_refspec_transform(ref, sizeof(ref), refspec, "refs/heads/master")); | |
51 | cl_assert(!strcmp(ref, "refs/remotes/test/master")); | |
52 | } |