From b22e7fa5a7bcd5492aaf9ec11f57cb4322eb8cb4 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Tue, 18 Jul 2017 23:12:09 +0200 Subject: utils: merkletrie fix test on windows --- utils/merkletrie/filesystem/node_test.go | 10 ++++++---- utils/merkletrie/index/node_test.go | 29 +++++++++++++++++------------ 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'utils') diff --git a/utils/merkletrie/filesystem/node_test.go b/utils/merkletrie/filesystem/node_test.go index bf1178a..6d764ab 100644 --- a/utils/merkletrie/filesystem/node_test.go +++ b/utils/merkletrie/filesystem/node_test.go @@ -4,6 +4,7 @@ import ( "bytes" "io" "os" + "path/filepath" "testing" . "gopkg.in/check.v1" @@ -133,18 +134,19 @@ func (s *NoderSuite) TestDiffChangeModeNotRelevant(c *C) { } func (s *NoderSuite) TestDiffDirectory(c *C) { + dir := filepath.Join("qux", "bar") fsA := memfs.New() - fsA.MkdirAll("qux/bar", 0644) + fsA.MkdirAll(dir, 0644) fsB := memfs.New() - fsB.MkdirAll("qux/bar", 0644) + fsB.MkdirAll(dir, 0644) ch, err := merkletrie.DiffTree( NewRootNode(fsA, map[string]plumbing.Hash{ - "qux/bar": plumbing.NewHash("aa102815663d23f8b75a47e7a01965dcdc96468c"), + dir: plumbing.NewHash("aa102815663d23f8b75a47e7a01965dcdc96468c"), }), NewRootNode(fsB, map[string]plumbing.Hash{ - "qux/bar": plumbing.NewHash("19102815663d23f8b75a47e7a01965dcdc96468c"), + dir: plumbing.NewHash("19102815663d23f8b75a47e7a01965dcdc96468c"), }), IsEquals, ) diff --git a/utils/merkletrie/index/node_test.go b/utils/merkletrie/index/node_test.go index 00da8da..283ca74 100644 --- a/utils/merkletrie/index/node_test.go +++ b/utils/merkletrie/index/node_test.go @@ -2,6 +2,7 @@ package index import ( "bytes" + "path/filepath" "testing" . "gopkg.in/check.v1" @@ -43,15 +44,17 @@ func (s *NoderSuite) TestDiff(c *C) { func (s *NoderSuite) TestDiffChange(c *C) { indexA := &index.Index{ - Entries: []*index.Entry{ - {Name: "bar/baz/bar", Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d")}, - }, + Entries: []*index.Entry{{ + Name: filepath.Join("bar", "baz", "bar"), + Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"), + }}, } indexB := &index.Index{ - Entries: []*index.Entry{ - {Name: "bar/baz/foo", Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d")}, - }, + Entries: []*index.Entry{{ + Name: filepath.Join("bar", "baz", "foo"), + Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"), + }}, } ch, err := merkletrie.DiffTree(NewRootNode(indexA), NewRootNode(indexB), isEquals) @@ -61,15 +64,17 @@ func (s *NoderSuite) TestDiffChange(c *C) { func (s *NoderSuite) TestDiffDir(c *C) { indexA := &index.Index{ - Entries: []*index.Entry{ - {Name: "foo", Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d")}, - }, + Entries: []*index.Entry{{ + Name: "foo", + Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"), + }}, } indexB := &index.Index{ - Entries: []*index.Entry{ - {Name: "foo/bar", Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d")}, - }, + Entries: []*index.Entry{{ + Name: filepath.Join("foo", "bar"), + Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"), + }}, } ch, err := merkletrie.DiffTree(NewRootNode(indexA), NewRootNode(indexB), isEquals) -- cgit