Support for git_odb_hash. #52

Merged
ursachec merged 3 commits from master into master 2014-02-23 09:02:35 -06:00
1 changed files with 27 additions and 0 deletions
Showing only changes of commit 53f2ebce5f - Show all commits

View File

@ -32,4 +32,31 @@ func TestOdbStream(t *testing.T) {
if stream.Id.Cmp(expectedId) != 0 { if stream.Id.Cmp(expectedId) != 0 {
t.Fatal("Wrong data written") t.Fatal("Wrong data written")
} }
}
func TestOdbHash(t *testing.T) {
repo := createTestRepo(t)
defer os.RemoveAll(repo.Workdir())
_, _ = seedTestRepo(t, repo)
odb, error := repo.Odb()
checkFatal(t, error)
str := `tree 115fcae49287c82eb55bb275cbbd4556fbed72b7
parent 66e1c476199ebcd3e304659992233132c5a52c6c
author John Doe <john@doe.com> 1390682018 +0000
committer John Doe <john@doe.com> 1390682018 +0000
Initial commit.`;
oid, error := odb.Hash([]byte(str), ObjectCommit)
checkFatal(t, error)
coid, error := odb.Write([]byte(str), ObjectCommit)
checkFatal(t, error)
if oid.Cmp(coid) != 0 {
t.Fatal("Hash and write Oids are different")
}
} }