-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathtest.git.h
More file actions
54 lines (47 loc) · 1.32 KB
/
test.git.h
File metadata and controls
54 lines (47 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright (c) 2022 Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
#pragma once
#include "test.common.h"
#include "git_api.h"
int TestGitAPI()
{
TEST_START();
GitAPI git(false);
TEST(git.InitializeRepository("/tmp/test-repo"), true);
git.CreateIndex();
git.AddFileToIndex("//a/b/c/foo.txt", { 'x', 'y', 'z' });
git.Commit(
"//a/b/c/...",
"12345678",
"test.user",
"test@user",
0,
"Test description",
10000000);
TEST(git.IsHEADExists(), true);
TEST(git.IsRepositoryClonedFrom("//a/b/c/..."), true);
TEST(git.IsRepositoryClonedFrom("//a/b/c/d/..."), false);
TEST(git.IsRepositoryClonedFrom("//x/y/z/..."), false);
TEST(git.DetectLatestCL(), "12345678");
git.RemoveFileFromIndex("//a/b/c/foo.txt");
git.Commit(
"//a/b/c/...",
"12345679",
"test.user.2",
"test2@user",
0,
"Test description",
20000000);
TEST(git.IsHEADExists(), true);
TEST(git.IsRepositoryClonedFrom("//a/b/c/..."), true);
TEST(git.IsRepositoryClonedFrom("//a/b/c/d/..."), false);
TEST(git.IsRepositoryClonedFrom("//x/y/z/..."), false);
TEST(git.DetectLatestCL(), "12345679");
git.CloseIndex();
TEST_END();
return TEST_EXIT_CODE();
}