generated from snivilised/astrolib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(kernel): add universal navigator tests (#62)
- Loading branch information
1 parent
7d5815d
commit fbfe00a
Showing
28 changed files
with
339 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
package kernel | ||
|
||
import ( | ||
"github.com/snivilised/traverse/core" | ||
"github.com/snivilised/traverse/internal/types" | ||
"github.com/snivilised/traverse/pref" | ||
) | ||
|
||
type ( | ||
Artefacts struct { | ||
Navigator core.Navigator | ||
Controller types.KernelController | ||
Mediator types.Mediator | ||
Facilities types.Facilities | ||
Resources *types.Resources | ||
Completion types.Completion | ||
} | ||
|
||
NavigatorBuilder interface { | ||
Build(o *pref.Options, res *types.Resources) (*Artefacts, error) | ||
Build(o *pref.Options, | ||
resources *types.Resources, | ||
) (*Artefacts, error) | ||
} | ||
|
||
Builder func(o *pref.Options, res *types.Resources) (*Artefacts, error) | ||
Builder func(o *pref.Options, | ||
resources *types.Resources, | ||
) (*Artefacts, error) | ||
) | ||
|
||
func (fn Builder) Build(o *pref.Options, res *types.Resources) (*Artefacts, error) { | ||
return fn(o, res) | ||
func (fn Builder) Build(o *pref.Options, | ||
resources *types.Resources, | ||
) (*Artefacts, error) { | ||
return fn(o, resources) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,70 @@ | ||
package kernel_test | ||
|
||
import ( | ||
"io/fs" | ||
|
||
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok | ||
. "github.com/onsi/gomega" //nolint:revive // ok | ||
"github.com/snivilised/traverse/core" | ||
"github.com/snivilised/traverse/cycle" | ||
"github.com/snivilised/traverse/enums" | ||
"github.com/snivilised/traverse/internal/helpers" | ||
) | ||
|
||
const ( | ||
RootPath = "traversal-root-path" | ||
RestorePath = "/from-restore-path" | ||
) | ||
|
||
type recordingMap map[string]int | ||
type recordingScopeMap map[string]enums.FilterScope | ||
type recordingOrderMap map[string]int | ||
|
||
type directoryQuantities struct { | ||
files uint | ||
folders uint | ||
children map[string]int | ||
} | ||
|
||
type naviTE struct { | ||
message string | ||
should string | ||
relative string | ||
once bool | ||
visit bool | ||
caseSensitive bool | ||
subscription enums.Subscription | ||
callback core.Client | ||
mandatory []string | ||
prohibited []string | ||
expectedNoOf directoryQuantities | ||
} | ||
|
||
func begin(em string) cycle.BeginHandler { | ||
return func(root string) { | ||
GinkgoWriter.Printf( | ||
"---> %v [traverse-navigator-test:BEGIN], root: '%v'\n", em, root, | ||
) | ||
} | ||
} | ||
|
||
func universalCallback(name string) core.Client { | ||
return func(node *core.Node) error { | ||
depth := node.Extension.Depth | ||
GinkgoWriter.Printf( | ||
"---> 🌊 UNIVERSAL//%v-CALLBACK: (depth:%v) '%v'\n", name, depth, node.Path, | ||
) | ||
Expect(node.Extension).NotTo(BeNil(), helpers.Reason(node.Path)) | ||
return nil | ||
} | ||
} | ||
|
||
func subscribes(subscription enums.Subscription, de fs.DirEntry) bool { | ||
isAnySubscription := (subscription == enums.SubscribeUniversal) | ||
|
||
files := (subscription == enums.SubscribeFiles) && (!de.IsDir()) | ||
folders := ((subscription == enums.SubscribeFolders) || | ||
subscription == enums.SubscribeFoldersWithFiles) && (de.IsDir()) | ||
|
||
return isAnySubscription || files || folders | ||
} |
Oops, something went wrong.