use filetree reader instead of filetree

This commit is contained in:
Alex Goodman
2020-06-02 08:52:26 -04:00
parent f0b8aaacda
commit cc724bff26
6 changed files with 459 additions and 13 deletions
+2 -2
View File
@@ -9,12 +9,12 @@ import (
type Scope struct {
Option Option
Trees []*tree.FileTree
Trees []tree.FileTreeReader
Image *image.Image
}
func NewScope(img *image.Image, option Option) (Scope, error) {
var trees = make([]*tree.FileTree, 0)
var trees = make([]tree.FileTreeReader, 0)
if img == nil {
return Scope{}, fmt.Errorf("no image given")
+5 -1
View File
@@ -81,7 +81,11 @@ func TestScope(t *testing.T) {
t.Fatalf("mismatched tree lengths: %d!=%d", len(actual.Trees), len(c.expectedTrees))
}
for idx, at := range actual.Trees {
for idx, atr := range actual.Trees {
at, ok := atr.(*tree.FileTree)
if !ok {
t.Fatalf("could not extract tree from reader")
}
if !at.Equal(c.expectedTrees[idx]) {
t.Error("mismatched tree @ idx", idx)
}