diff options
| author | Jesse Ezell <[email protected]> | 2014-03-20 22:02:19 -0700 |
|---|---|---|
| committer | Jesse Ezell <[email protected]> | 2014-03-20 22:02:19 -0700 |
| commit | 37964e878f70229171f94668cb96f347b798e2b2 (patch) | |
| tree | 5781761e13e57edb3589844b6faa799c1158b93a /odb_test.go | |
| parent | d0b334b24409ddc190a7010be0072d87df6b6bfe (diff) | |
| parent | 2811845a1287d949a74b8ed80a5791fd8875002a (diff) | |
merge with latest
Diffstat (limited to 'odb_test.go')
| -rw-r--r-- | odb_test.go | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/odb_test.go b/odb_test.go index 3c7624c..17b3ad2 100644 --- a/odb_test.go +++ b/odb_test.go @@ -27,9 +27,36 @@ func TestOdbStream(t *testing.T) { error = stream.Close() checkFatal(t, error) - expectedId, error := NewOidFromString("30f51a3fba5274d53522d0f19748456974647b4f") + expectedId, error := NewOid("30f51a3fba5274d53522d0f19748456974647b4f") checkFatal(t, error) if stream.Id.Cmp(expectedId) != 0 { t.Fatal("Wrong data written") } -}
\ No newline at end of file +} + +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 <[email protected]> 1390682018 +0000 +committer John Doe <[email protected]> 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") + } +} |
