forked from pockethub/PocketHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRefUtilsTest.java
More file actions
106 lines (95 loc) · 4.13 KB
/
RefUtilsTest.java
File metadata and controls
106 lines (95 loc) · 4.13 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Copyright 2012 GitHub Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.mobile.tests.ref;
import android.test.AndroidTestCase;
import com.github.mobile.core.ref.RefUtils;
import org.eclipse.egit.github.core.Reference;
/**
* Tests of {@link RefUtils}
*/
public class RefUtilsTest extends AndroidTestCase {
/**
* Verify {@link RefUtils#isBranch(org.eclipse.egit.github.core.Reference)}
*/
public void testIsBranch() {
assertFalse(RefUtils.isBranch(null));
assertFalse(RefUtils.isBranch(new Reference()));
assertFalse(RefUtils.isBranch(new Reference().setRef("")));
assertFalse(RefUtils.isBranch(new Reference().setRef("test")));
assertFalse(RefUtils.isBranch(new Reference().setRef("refs/tags/v1")));
assertFalse(RefUtils.isBranch(new Reference().setRef("refs/b1")));
assertTrue(RefUtils.isBranch(new Reference().setRef("refs/heads/b2")));
}
/**
* Verify {@link RefUtils#isTag(org.eclipse.egit.github.core.Reference)}
*/
public void testIsTag() {
assertFalse(RefUtils.isTag((Reference) null));
assertFalse(RefUtils.isTag(new Reference()));
assertFalse(RefUtils.isTag(new Reference().setRef("")));
assertFalse(RefUtils.isTag(new Reference().setRef("test")));
assertFalse(RefUtils.isTag(new Reference().setRef("refs/b1")));
assertFalse(RefUtils.isTag(new Reference().setRef("refs/heads/b2")));
assertTrue(RefUtils.isTag(new Reference().setRef("refs/tags/v1")));
}
/**
* Verify {@link RefUtils#isValid(org.eclipse.egit.github.core.Reference)}
*/
public void testIsValid() {
assertFalse(RefUtils.isValid(null));
assertFalse(RefUtils.isValid(new Reference()));
assertFalse(RefUtils.isValid(new Reference().setRef("")));
assertFalse(RefUtils.isValid(new Reference()
.setRef("refs/pull/6/merge")));
assertFalse(RefUtils
.isValid(new Reference().setRef("refs/pull/6/head")));
assertTrue(RefUtils.isValid(new Reference().setRef("refs/pull")));
assertTrue(RefUtils.isValid(new Reference().setRef("refs/heads/b1")));
assertTrue(RefUtils.isValid(new Reference().setRef("refs/tags/v1")));
}
/**
* Verify {@link RefUtils#getName(Reference)}
*/
public void testGetName() {
assertNull(RefUtils.getName((Reference) null));
assertNull(RefUtils.getName(new Reference()));
assertEquals("", RefUtils.getName(new Reference().setRef("")));
assertEquals("unchanged",
RefUtils.getName(new Reference().setRef("unchanged")));
assertEquals("branch",
RefUtils.getName(new Reference().setRef("refs/heads/branch")));
assertEquals("tag",
RefUtils.getName(new Reference().setRef("refs/tags/tag")));
assertEquals("notes",
RefUtils.getName(new Reference().setRef("refs/notes")));
}
/**
* Verify {@link RefUtils#getPath(Reference)}
*/
public void testGetPath() {
assertNull(RefUtils.getPath(null));
assertNull(RefUtils.getPath(new Reference()));
assertEquals("", RefUtils.getPath(new Reference().setRef("")));
assertEquals("unchanged",
RefUtils.getPath(new Reference().setRef("unchanged")));
assertEquals("heads/branch",
RefUtils.getPath(new Reference().setRef("refs/heads/branch")));
assertEquals("tags/tag",
RefUtils.getPath(new Reference().setRef("refs/tags/tag")));
assertEquals("notes",
RefUtils.getPath(new Reference().setRef("refs/notes")));
}
}