Skip to content

Commit

Permalink
Added unit test coverage for notebooks. Added better error logic for …
Browse files Browse the repository at this point in the history
…fetching recursive paths. Errors will fail the recursive call.
  • Loading branch information
stikkireddy committed Apr 20, 2020
1 parent bcdfe87 commit 1499ec2
Show file tree
Hide file tree
Showing 2 changed files with 401 additions and 5 deletions.
20 changes: 15 additions & 5 deletions client/service/notebooks.go
Expand Up @@ -75,22 +75,32 @@ func (a NotebooksAPI) Mkdirs(path string) error {
func (a NotebooksAPI) List(path string, recursive bool) ([]model.NotebookInfo, error) {
if recursive == true {
var paths []model.NotebookInfo
a.recursiveAddPaths(path, &paths)
return paths, nil
err := a.recursiveAddPaths(path, &paths)
if err != nil {
return nil, err
}
return paths, err
} else {
return a.list(path)
}
}

func (a NotebooksAPI) recursiveAddPaths(path string, pathList *[]model.NotebookInfo) {
notebookInfoList, _ := a.list(path)
func (a NotebooksAPI) recursiveAddPaths(path string, pathList *[]model.NotebookInfo) error {
notebookInfoList, err := a.list(path)
if err != nil {
return err
}
for _, v := range notebookInfoList {
if v.ObjectType == model.Notebook {
*pathList = append(*pathList, v)
} else if v.ObjectType == model.Directory {
a.recursiveAddPaths(v.Path, pathList)
err := a.recursiveAddPaths(v.Path, pathList)
if err != nil {
return err
}
}
}
return err
}

func (a NotebooksAPI) list(path string) ([]model.NotebookInfo, error) {
Expand Down

0 comments on commit 1499ec2

Please sign in to comment.