diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-02 00:44:06 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-02 00:44:06 +0100 |
commit | 6996381ae43936e7365395e90c8f93372e49be9f (patch) | |
tree | ed0d9441157a62230b0b9ca57ef600fd2ba99f76 /tree_diff_test.go | |
parent | c15bf1dff332873644290db0e186b8f5ad9b8fb2 (diff) | |
download | go-git-6996381ae43936e7365395e90c8f93372e49be9f.tar.gz |
BaseSuite improvements, usage of file:// proto
Diffstat (limited to 'tree_diff_test.go')
-rw-r--r-- | tree_diff_test.go | 376 |
1 files changed, 173 insertions, 203 deletions
diff --git a/tree_diff_test.go b/tree_diff_test.go index 81fee5d..e7e41c7 100644 --- a/tree_diff_test.go +++ b/tree_diff_test.go @@ -15,11 +15,6 @@ type DiffTreeSuite struct { var _ = Suite(&DiffTreeSuite{}) -func (s *DiffTreeSuite) SetUpSuite(c *C) { - s.BaseSuite.SetUpSuite(c) - s.buildRepositories(c, fixtures.ByTag("diff-tree")) -} - func (s *DiffTreeSuite) TestActionString(c *C) { expected := "Insert" action := Insert @@ -129,228 +124,203 @@ type expectChange struct { func (s *DiffTreeSuite) TestDiffTree(c *C) { for i, t := range []struct { - repo string // the repo name as in localRepos - commit1 string // the commit of the first tree - commit2 string // the commit of the second tree - expected []expectChange // the expected list of []changeExpect - }{ - { - "https://github.com/dezfowler/LiteMock.git", - "", - "", - []expectChange{}, - }, - { - "https://github.com/dezfowler/LiteMock.git", - "b7965eaa2c4f245d07191fe0bcfe86da032d672a", - "b7965eaa2c4f245d07191fe0bcfe86da032d672a", - []expectChange{}, - }, - { - "https://github.com/dezfowler/LiteMock.git", - "", - "b7965eaa2c4f245d07191fe0bcfe86da032d672a", - []expectChange{ - {Action: Insert, Name: "README"}, - }, - }, - { - "https://github.com/dezfowler/LiteMock.git", - "b7965eaa2c4f245d07191fe0bcfe86da032d672a", - "", - []expectChange{ - {Action: Delete, Name: "README"}, - }, - }, - { - "https://github.com/githubtraining/example-branches.git", - "", - "f0eb272cc8f77803478c6748103a1450aa1abd37", - []expectChange{ - {Action: Insert, Name: "README.md"}, - }, - }, - { - "https://github.com/githubtraining/example-branches.git", - "f0eb272cc8f77803478c6748103a1450aa1abd37", - "", - []expectChange{ - {Action: Delete, Name: "README.md"}, - }, + repository string // the repo name as in localRepos + commit1 string // the commit of the first tree + commit2 string // the commit of the second tree + expected []expectChange // the expected list of []changeExpect + }{{ + "https://github.com/dezfowler/LiteMock.git", + "", + "", + []expectChange{}, + }, { + "https://github.com/dezfowler/LiteMock.git", + "b7965eaa2c4f245d07191fe0bcfe86da032d672a", + "b7965eaa2c4f245d07191fe0bcfe86da032d672a", + []expectChange{}, + }, { + "https://github.com/dezfowler/LiteMock.git", + "", + "b7965eaa2c4f245d07191fe0bcfe86da032d672a", + []expectChange{ + {Action: Insert, Name: "README"}, }, - { - "https://github.com/githubtraining/example-branches.git", - "f0eb272cc8f77803478c6748103a1450aa1abd37", - "f0eb272cc8f77803478c6748103a1450aa1abd37", - []expectChange{}, + }, { + "https://github.com/dezfowler/LiteMock.git", + "b7965eaa2c4f245d07191fe0bcfe86da032d672a", + "", + []expectChange{ + {Action: Delete, Name: "README"}, }, - { - "https://github.com/github/gem-builder.git", - "", - "9608eed92b3839b06ebf72d5043da547de10ce85", - []expectChange{ - {Action: Insert, Name: "README"}, - {Action: Insert, Name: "gem_builder.rb"}, - {Action: Insert, Name: "gem_eval.rb"}, - }, + }, { + "https://github.com/githubtraining/example-branches.git", + "", + "f0eb272cc8f77803478c6748103a1450aa1abd37", + []expectChange{ + {Action: Insert, Name: "README.md"}, }, - { - "https://github.com/github/gem-builder.git", - "9608eed92b3839b06ebf72d5043da547de10ce85", - "", - []expectChange{ - {Action: Delete, Name: "README"}, - {Action: Delete, Name: "gem_builder.rb"}, - {Action: Delete, Name: "gem_eval.rb"}, - }, + }, { + "https://github.com/githubtraining/example-branches.git", + "f0eb272cc8f77803478c6748103a1450aa1abd37", + "", + []expectChange{ + {Action: Delete, Name: "README.md"}, }, - { - "https://github.com/github/gem-builder.git", - "9608eed92b3839b06ebf72d5043da547de10ce85", - "9608eed92b3839b06ebf72d5043da547de10ce85", - []expectChange{}, + }, { + "https://github.com/githubtraining/example-branches.git", + "f0eb272cc8f77803478c6748103a1450aa1abd37", + "f0eb272cc8f77803478c6748103a1450aa1abd37", + []expectChange{}, + }, { + "https://github.com/github/gem-builder.git", + "", + "9608eed92b3839b06ebf72d5043da547de10ce85", + []expectChange{ + {Action: Insert, Name: "README"}, + {Action: Insert, Name: "gem_builder.rb"}, + {Action: Insert, Name: "gem_eval.rb"}, }, - { - "https://github.com/toqueteos/ts3.git", - "", - "764e914b75d6d6df1fc5d832aa9840f590abf1bb", - []expectChange{ - {Action: Insert, Name: "README.markdown"}, - {Action: Insert, Name: "examples/bot.go"}, - {Action: Insert, Name: "examples/raw_shell.go"}, - {Action: Insert, Name: "helpers.go"}, - {Action: Insert, Name: "ts3.go"}, - }, + }, { + "https://github.com/github/gem-builder.git", + "9608eed92b3839b06ebf72d5043da547de10ce85", + "", + []expectChange{ + {Action: Delete, Name: "README"}, + {Action: Delete, Name: "gem_builder.rb"}, + {Action: Delete, Name: "gem_eval.rb"}, }, - { - "https://github.com/toqueteos/ts3.git", - "764e914b75d6d6df1fc5d832aa9840f590abf1bb", - "", - []expectChange{ - {Action: Delete, Name: "README.markdown"}, - {Action: Delete, Name: "examples/bot.go"}, - {Action: Delete, Name: "examples/raw_shell.go"}, - {Action: Delete, Name: "helpers.go"}, - {Action: Delete, Name: "ts3.go"}, - }, + }, { + "https://github.com/github/gem-builder.git", + "9608eed92b3839b06ebf72d5043da547de10ce85", + "9608eed92b3839b06ebf72d5043da547de10ce85", + []expectChange{}, + }, { + "https://github.com/toqueteos/ts3.git", + "", + "764e914b75d6d6df1fc5d832aa9840f590abf1bb", + []expectChange{ + {Action: Insert, Name: "README.markdown"}, + {Action: Insert, Name: "examples/bot.go"}, + {Action: Insert, Name: "examples/raw_shell.go"}, + {Action: Insert, Name: "helpers.go"}, + {Action: Insert, Name: "ts3.go"}, }, - { - "https://github.com/toqueteos/ts3.git", - "764e914b75d6d6df1fc5d832aa9840f590abf1bb", - "764e914b75d6d6df1fc5d832aa9840f590abf1bb", - []expectChange{}, + }, { + "https://github.com/toqueteos/ts3.git", + "764e914b75d6d6df1fc5d832aa9840f590abf1bb", + "", + []expectChange{ + {Action: Delete, Name: "README.markdown"}, + {Action: Delete, Name: "examples/bot.go"}, + {Action: Delete, Name: "examples/raw_shell.go"}, + {Action: Delete, Name: "helpers.go"}, + {Action: Delete, Name: "ts3.go"}, }, - { - "https://github.com/github/gem-builder.git", - "9608eed92b3839b06ebf72d5043da547de10ce85", - "6c41e05a17e19805879689414026eb4e279f7de0", - []expectChange{ - {Action: Modify, Name: "gem_eval.rb"}, - }, + }, { + "https://github.com/toqueteos/ts3.git", + "764e914b75d6d6df1fc5d832aa9840f590abf1bb", + "764e914b75d6d6df1fc5d832aa9840f590abf1bb", + []expectChange{}, + }, { + "https://github.com/github/gem-builder.git", + "9608eed92b3839b06ebf72d5043da547de10ce85", + "6c41e05a17e19805879689414026eb4e279f7de0", + []expectChange{ + {Action: Modify, Name: "gem_eval.rb"}, }, - { - "https://github.com/github/gem-builder.git", - "6c41e05a17e19805879689414026eb4e279f7de0", - "89be3aac2f178719c12953cc9eaa23441f8d9371", - []expectChange{ - {Action: Modify, Name: "gem_eval.rb"}, - {Action: Insert, Name: "gem_eval_test.rb"}, - {Action: Insert, Name: "security.rb"}, - {Action: Insert, Name: "security_test.rb"}, - }, + }, { + "https://github.com/github/gem-builder.git", + "6c41e05a17e19805879689414026eb4e279f7de0", + "89be3aac2f178719c12953cc9eaa23441f8d9371", + []expectChange{ + {Action: Modify, Name: "gem_eval.rb"}, + {Action: Insert, Name: "gem_eval_test.rb"}, + {Action: Insert, Name: "security.rb"}, + {Action: Insert, Name: "security_test.rb"}, }, - { - "https://github.com/github/gem-builder.git", - "89be3aac2f178719c12953cc9eaa23441f8d9371", - "597240b7da22d03ad555328f15abc480b820acc0", - []expectChange{ - {Action: Modify, Name: "gem_eval.rb"}, - }, + }, { + "https://github.com/github/gem-builder.git", + "89be3aac2f178719c12953cc9eaa23441f8d9371", + "597240b7da22d03ad555328f15abc480b820acc0", + []expectChange{ + {Action: Modify, Name: "gem_eval.rb"}, }, - { - "https://github.com/github/gem-builder.git", - "597240b7da22d03ad555328f15abc480b820acc0", - "0260380e375d2dd0e1a8fcab15f91ce56dbe778e", - []expectChange{ - {Action: Modify, Name: "gem_eval.rb"}, - {Action: Modify, Name: "gem_eval_test.rb"}, - {Action: Insert, Name: "lazy_dir.rb"}, - {Action: Insert, Name: "lazy_dir_test.rb"}, - {Action: Modify, Name: "security.rb"}, - {Action: Modify, Name: "security_test.rb"}, - }, + }, { + "https://github.com/github/gem-builder.git", + "597240b7da22d03ad555328f15abc480b820acc0", + "0260380e375d2dd0e1a8fcab15f91ce56dbe778e", + []expectChange{ + {Action: Modify, Name: "gem_eval.rb"}, + {Action: Modify, Name: "gem_eval_test.rb"}, + {Action: Insert, Name: "lazy_dir.rb"}, + {Action: Insert, Name: "lazy_dir_test.rb"}, + {Action: Modify, Name: "security.rb"}, + {Action: Modify, Name: "security_test.rb"}, }, - { - "https://github.com/github/gem-builder.git", - "0260380e375d2dd0e1a8fcab15f91ce56dbe778e", - "597240b7da22d03ad555328f15abc480b820acc0", - []expectChange{ - {Action: Modify, Name: "gem_eval.rb"}, - {Action: Modify, Name: "gem_eval_test.rb"}, - {Action: Delete, Name: "lazy_dir.rb"}, - {Action: Delete, Name: "lazy_dir_test.rb"}, - {Action: Modify, Name: "security.rb"}, - {Action: Modify, Name: "security_test.rb"}, - }, + }, { + "https://github.com/github/gem-builder.git", + "0260380e375d2dd0e1a8fcab15f91ce56dbe778e", + "597240b7da22d03ad555328f15abc480b820acc0", + []expectChange{ + {Action: Modify, Name: "gem_eval.rb"}, + {Action: Modify, Name: "gem_eval_test.rb"}, + {Action: Delete, Name: "lazy_dir.rb"}, + {Action: Delete, Name: "lazy_dir_test.rb"}, + {Action: Modify, Name: "security.rb"}, + {Action: Modify, Name: "security_test.rb"}, }, - { - "https://github.com/github/gem-builder.git", - "0260380e375d2dd0e1a8fcab15f91ce56dbe778e", - "ca9fd470bacb6262eb4ca23ee48bb2f43711c1ff", - []expectChange{ - {Action: Modify, Name: "gem_eval.rb"}, - {Action: Modify, Name: "security.rb"}, - {Action: Modify, Name: "security_test.rb"}, - }, + }, { + "https://github.com/github/gem-builder.git", + "0260380e375d2dd0e1a8fcab15f91ce56dbe778e", + "ca9fd470bacb6262eb4ca23ee48bb2f43711c1ff", + []expectChange{ + {Action: Modify, Name: "gem_eval.rb"}, + {Action: Modify, Name: "security.rb"}, + {Action: Modify, Name: "security_test.rb"}, }, - { - "https://github.com/github/gem-builder.git", - "fe3c86745f887c23a0d38c85cfd87ca957312f86", - "b7e3f636febf7a0cd3ab473b6d30081786d2c5b6", - []expectChange{ - {Action: Modify, Name: "gem_eval.rb"}, - {Action: Modify, Name: "gem_eval_test.rb"}, - {Action: Insert, Name: "git_mock"}, - {Action: Modify, Name: "lazy_dir.rb"}, - {Action: Modify, Name: "lazy_dir_test.rb"}, - {Action: Modify, Name: "security.rb"}, - }, + }, { + "https://github.com/github/gem-builder.git", + "fe3c86745f887c23a0d38c85cfd87ca957312f86", + "b7e3f636febf7a0cd3ab473b6d30081786d2c5b6", + []expectChange{ + {Action: Modify, Name: "gem_eval.rb"}, + {Action: Modify, Name: "gem_eval_test.rb"}, + {Action: Insert, Name: "git_mock"}, + {Action: Modify, Name: "lazy_dir.rb"}, + {Action: Modify, Name: "lazy_dir_test.rb"}, + {Action: Modify, Name: "security.rb"}, }, - { - "https://github.com/rumpkernel/rumprun-xen.git", - "1831e47b0c6db750714cd0e4be97b5af17fb1eb0", - "51d8515578ea0c88cc8fc1a057903675cf1fc16c", - []expectChange{ - {Action: Modify, Name: "Makefile"}, - {Action: Modify, Name: "netbsd_init.c"}, - {Action: Modify, Name: "rumphyper_stubs.c"}, - {Action: Delete, Name: "sysproxy.c"}, - }, + }, { + "https://github.com/rumpkernel/rumprun-xen.git", + "1831e47b0c6db750714cd0e4be97b5af17fb1eb0", + "51d8515578ea0c88cc8fc1a057903675cf1fc16c", + []expectChange{ + {Action: Modify, Name: "Makefile"}, + {Action: Modify, Name: "netbsd_init.c"}, + {Action: Modify, Name: "rumphyper_stubs.c"}, + {Action: Delete, Name: "sysproxy.c"}, }, - { - "https://github.com/rumpkernel/rumprun-xen.git", - "1831e47b0c6db750714cd0e4be97b5af17fb1eb0", - "e13e678f7ee9badd01b120889e0ec5fdc8ae3802", - []expectChange{ - {Action: Modify, Name: "app-tools/rumprun"}, - }, + }, { + "https://github.com/rumpkernel/rumprun-xen.git", + "1831e47b0c6db750714cd0e4be97b5af17fb1eb0", + "e13e678f7ee9badd01b120889e0ec5fdc8ae3802", + []expectChange{ + {Action: Modify, Name: "app-tools/rumprun"}, }, - } { - repo, ok := s.Repositories[t.repo] - c.Assert(ok, Equals, true, - Commentf("subtest %d: repo %s not found", i, t.repo)) + }} { + r := s.NewRepositoryFromPackfile(fixtures.ByURL(t.repository).One()) - tree1, err := tree(repo, t.commit1) + tree1, err := tree(r, t.commit1) c.Assert(err, IsNil, - Commentf("subtest %d: unable to retrieve tree from commit %s and repo %s: %s", i, t.commit1, t.repo, err)) + Commentf("subtest %d: unable to retrieve tree from commit %s and repo %s: %s", i, t.commit1, t.repository, err)) var tree2 *Tree if t.commit1 == t.commit2 { tree2 = tree1 } else { - tree2, err = tree(repo, t.commit2) + tree2, err = tree(r, t.commit2) c.Assert(err, IsNil, - Commentf("subtest %d: unable to retrieve tree from commit %s and repo %s", i, t.commit2, t.repo, err)) + Commentf("subtest %d: unable to retrieve tree from commit %s and repo %s", i, t.commit2, t.repository, err)) } obtained, err := DiffTree(tree1, tree2) @@ -358,7 +328,7 @@ func (s *DiffTreeSuite) TestDiffTree(c *C) { Commentf("subtest %d: unable to calculate difftree: %s", i, err)) c.Assert(equalChanges(obtained, t.expected), Equals, true, Commentf("subtest:%d\nrepo=%s\ncommit1=%s\ncommit2=%s\nexpected=%s\nobtained=%s", - i, t.repo, t.commit1, t.commit2, t.expected, obtained)) + i, t.repository, t.commit1, t.commit2, t.expected, obtained)) assertChanges(obtained, c) } |