Index: add failing tests for a standalone Index

The index can exist purely as a data structure. Let's test that so we
make sure we support that.
This commit is contained in:
Carlos Martín Nieto
2014-05-27 18:06:28 +02:00
parent 19be4b6aa4
commit 97c0e476a3

View File

@@ -34,7 +34,7 @@ import unittest
import tempfile
import pygit2
from pygit2 import Repository
from pygit2 import Repository, Index
from . import utils
@@ -206,5 +206,19 @@ class IndexEntryTest(utils.RepoTestCase):
tree_id = index.write_tree()
self.assertEqual('60e769e57ae1d6a2ab75d8d253139e6260e1f912', str(tree_id))
class StandaloneIndexTest(utils.RepoTestCase):
def test_create_empty(self):
index = Index()
def test_create_empty_read_tree_as_string(self):
index = Index()
# no repo associated, so we don't know where to read from
self.assertRaises(TypeError, index, 'read_tree', 'fd937514cb799514d4b81bb24c5fcfeb6472b245')
def test_create_empty_read_tree(self):
index = Index()
index.read_tree(self.repo['fd937514cb799514d4b81bb24c5fcfeb6472b245'])
if __name__ == '__main__':
unittest.main()