Failed to sort by dependency
tennashi opened this issue · 0 comments
tennashi commented
The following test for the sortByDepends()
function fails.
package plugconf |
|
import ( |
"reflect" |
"testing" |
|
"github.com/vim-volt/volt/lockjson" |
"github.com/vim-volt/volt/pathutil" |
) |
|
func TestSortByDepends(t *testing.T) { |
reposList := []lockjson.Repos{ |
{Path: pathutil.DecodeReposPath("test/test-1")}, |
{Path: pathutil.DecodeReposPath("test/test-2")}, |
{Path: pathutil.DecodeReposPath("test/test-3")}, |
} |
|
plugconfMap := map[pathutil.ReposPath]*ParsedInfo{ |
pathutil.DecodeReposPath("test/test-1"): { |
depends: []pathutil.ReposPath{ |
pathutil.DecodeReposPath("test/test-2"), |
}, |
}, |
pathutil.DecodeReposPath("test/test-2"): { |
depends: []pathutil.ReposPath{ |
pathutil.DecodeReposPath("test/test-3"), |
}, |
}, |
pathutil.DecodeReposPath("test/test-3"): {}, |
} |
|
sortByDepends(reposList, plugconfMap)
|
want := []lockjson.Repos{ |
{Path: pathutil.DecodeReposPath("test/test-3")}, |
{Path: pathutil.DecodeReposPath("test/test-2")}, |
{Path: pathutil.DecodeReposPath("test/test-1")}, |
} |
|
if !reflect.DeepEqual(reposList, want) { |
t.Fatalf("want: %v, but got: %v", want, reposList) |
} |
}
The following is the result:
=== RUN TestSortByDepends
plugconf_test.go:41: want: [{ test-3 } { test-2 } { test-1 }], but got: [{ test-1 } { test-3 } { test-2 }]