MCPcopy Create free account
hub / github.com/libgit2/git2go / TestRefModification

Function TestRefModification

reference_test.go:10–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestRefModification(t *testing.T) {
11 t.Parallel()
12 repo := createTestRepo(t)
13 defer cleanupTestRepo(t, repo)
14
15 commitId, treeId := seedTestRepo(t, repo)
16
17 _, err := repo.References.Create("refs/tags/tree", treeId, true, "testTreeTag")
18 checkFatal(t, err)
19
20 tag, err := repo.References.Lookup("refs/tags/tree")
21 checkFatal(t, err)
22 checkRefType(t, tag, ReferenceOid)
23
24 ref, err := repo.References.Lookup("HEAD")
25 checkFatal(t, err)
26 checkRefType(t, ref, ReferenceSymbolic)
27
28 if target := ref.Target(); target != nil {
29 t.Fatalf("Expected nil *Oid, got %v", target)
30 }
31
32 ref, err = ref.Resolve()
33 checkFatal(t, err)
34 checkRefType(t, ref, ReferenceOid)
35
36 if target := ref.Target(); target == nil {
37 t.Fatalf("Expected valid target got nil")
38 }
39
40 if target := ref.SymbolicTarget(); target != "" {
41 t.Fatalf("Expected empty string, got %v", target)
42 }
43
44 if commitId.String() != ref.Target().String() {
45 t.Fatalf("Wrong ref target")
46 }
47
48 _, err = tag.Rename("refs/tags/renamed", false, "")
49 checkFatal(t, err)
50 tag, err = repo.References.Lookup("refs/tags/renamed")
51 checkFatal(t, err)
52 checkRefType(t, ref, ReferenceOid)
53
54}
55
56func TestReferenceIterator(t *testing.T) {
57 t.Parallel()

Callers

nothing calls this directly

Calls 12

createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
seedTestRepoFunction · 0.85
checkFatalFunction · 0.85
checkRefTypeFunction · 0.85
ResolveMethod · 0.80
SymbolicTargetMethod · 0.80
CreateMethod · 0.45
LookupMethod · 0.45
TargetMethod · 0.45
StringMethod · 0.45
RenameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…