Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(laboratory): rename helpers pkg to laboratory (#171) #176

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions collections/positional-set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
. "github.com/onsi/gomega" //nolint:revive // ok

"github.com/snivilised/traverse/collections"
"github.com/snivilised/traverse/internal/helpers"
lab "github.com/snivilised/traverse/internal/laboratory"
)

var (
Expand All @@ -20,7 +20,7 @@ func assertColoursAreInOrder(set *collections.PositionalSet[string]) {

for _, colour := range rainbow {
pos, _ := set.Position(colour)
Expect(pos < anchor).To(BeTrue(), helpers.Reason(
Expect(pos < anchor).To(BeTrue(), lab.Reason(
fmt.Sprintf("position(%v) of colour: %v should be less than anchor's(%v)",
pos, colour, anchor),
))
Expand All @@ -47,38 +47,38 @@ var _ = Describe("PositionalSet", func() {
Context("Count", func() {
When("no items added", func() {
It("🧪 should: contain just the anchor", func() {
Expect(set.Count()).To(Equal(1), helpers.Reason("only anchor should be present"))
Expect(set.Count()).To(Equal(1), lab.Reason("only anchor should be present"))
})
})
})

Context("Insert", func() {
When("requested item is the anchor", func() {
It("🧪 should: not insert", func() {
Expect(set.Insert("ANCHOR")).To(BeFalse(), helpers.Reason("inserting anchor is invalid"))
Expect(set.Count()).To(Equal(1), helpers.Reason("only anchor should be present"))
Expect(set.Insert("ANCHOR")).To(BeFalse(), lab.Reason("inserting anchor is invalid"))
Expect(set.Count()).To(Equal(1), lab.Reason("only anchor should be present"))
})
})

When("valid item requested", func() {
It("🧪 should: insert", func() {
Expect(set.Insert("richard")).To(BeTrue(), helpers.Reason("richard is in order list"))
Expect(set.Count()).To(Equal(2), helpers.Reason("richard, anchor"))
Expect(set.Insert("richard")).To(BeTrue(), lab.Reason("richard is in order list"))
Expect(set.Count()).To(Equal(2), lab.Reason("richard, anchor"))
})
})

When("valid item already present", func() {
It("🧪 should: not insert", func() {
set.Insert("richard")
Expect(set.Insert("richard")).To(BeFalse(), helpers.Reason("richard already in order list"))
Expect(set.Count()).To(Equal(2), helpers.Reason("richard, anchor"))
Expect(set.Insert("richard")).To(BeFalse(), lab.Reason("richard already in order list"))
Expect(set.Count()).To(Equal(2), lab.Reason("richard, anchor"))
})
})

When("invalid item requested", func() {
It("🧪 should: not insert", func() {
Expect(set.Insert("gold")).To(BeFalse(), helpers.Reason("gold not in order list"))
Expect(set.Count()).To(Equal(1), helpers.Reason("only anchor should be present"))
Expect(set.Insert("gold")).To(BeFalse(), lab.Reason("gold not in order list"))
Expect(set.Count()).To(Equal(1), lab.Reason("only anchor should be present"))
})
})
})
Expand All @@ -88,17 +88,17 @@ var _ = Describe("PositionalSet", func() {
It("🧪 should: insert all", func() {
Expect(set.All(
"richard", "of", "york", "gave", "battle", "in", "vain",
)).To(BeTrue(), helpers.Reason("all items are valid"))
Expect(set.Count()).To(Equal(8), helpers.Reason("should contain all items"))
)).To(BeTrue(), lab.Reason("all items are valid"))
Expect(set.Count()).To(Equal(8), lab.Reason("should contain all items"))
})
})

When("Not all are valid", func() {
It("🧪 should: insert only valid", func() {
Expect(set.All(
"richard", "gold", "of", "silver", "york", "bronze",
)).To(BeFalse(), helpers.Reason("all items are valid"))
Expect(set.Count()).To(Equal(4), helpers.Reason("should contain valid items"))
)).To(BeFalse(), lab.Reason("all items are valid"))
Expect(set.Count()).To(Equal(4), lab.Reason("should contain valid items"))
})
})
})
Expand All @@ -107,29 +107,29 @@ var _ = Describe("PositionalSet", func() {
When("requested item is the anchor", func() {
It("🧪 should: not delete", func() {
set.Delete("ANCHOR")
Expect(set.Count()).To(Equal(1), helpers.Reason("anchor should still be present"))
Expect(set.Count()).To(Equal(1), lab.Reason("anchor should still be present"))
})
})

When("requested valid item is present", func() {
It("🧪 should: delete", func() {
set.Insert("york")
set.Delete("york")
Expect(set.Count()).To(Equal(1), helpers.Reason("york should deleted"))
Expect(set.Count()).To(Equal(1), lab.Reason("york should deleted"))
})
})

When("requested valid item is not present", func() {
It("🧪 should: not delete", func() {
set.Delete("york")
Expect(set.Count()).To(Equal(1), helpers.Reason("only anchor should be present"))
Expect(set.Count()).To(Equal(1), lab.Reason("only anchor should be present"))
})
})

When("requested valid item is not valid", func() {
It("🧪 should: not delete", func() {
set.Delete("silver")
Expect(set.Count()).To(Equal(1), helpers.Reason("only anchor should be present"))
Expect(set.Count()).To(Equal(1), lab.Reason("only anchor should be present"))
})
})
})
Expand Down
6 changes: 3 additions & 3 deletions internal/feat/filter/filter-suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
. "github.com/onsi/gomega" //nolint:revive // ok
"github.com/snivilised/traverse/core"
"github.com/snivilised/traverse/enums"
"github.com/snivilised/traverse/internal/helpers"
lab "github.com/snivilised/traverse/internal/laboratory"
"github.com/snivilised/traverse/internal/third/lo"
)

Expand All @@ -18,7 +18,7 @@ func TestFilter(t *testing.T) {
}

type FilterTE struct {
helpers.NaviTE
lab.NaviTE
Description string
Pattern string
Scope enums.FilterScope
Expand All @@ -31,7 +31,7 @@ type FilterTE struct {
}

type PolyTE struct {
helpers.NaviTE
lab.NaviTE
File core.FilterDef
Folder core.FilterDef
}
Expand Down
4 changes: 2 additions & 2 deletions internal/feat/hiber/hibernate-suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok
. "github.com/onsi/gomega" //nolint:revive // ok
"github.com/snivilised/traverse/core"
"github.com/snivilised/traverse/internal/helpers"
lab "github.com/snivilised/traverse/internal/laboratory"
)

func TestHibernate(t *testing.T) {
Expand All @@ -15,7 +15,7 @@ func TestHibernate(t *testing.T) {
}

type hibernateTE struct {
helpers.NaviTE
lab.NaviTE
Hibernate *core.HibernateOptions
Mute bool
}
40 changes: 20 additions & 20 deletions internal/feat/hiber/hibernate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
tv "github.com/snivilised/traverse"
"github.com/snivilised/traverse/core"
"github.com/snivilised/traverse/enums"
"github.com/snivilised/traverse/internal/helpers"
lab "github.com/snivilised/traverse/internal/laboratory"
"github.com/snivilised/traverse/internal/services"
"github.com/snivilised/traverse/internal/third/lo"
)
Expand All @@ -30,7 +30,7 @@ var _ = Describe("feature", Ordered, func() {
verbose = false
)

FS, root = helpers.Musico(verbose,
FS, root = lab.Musico(verbose,
filepath.Join("MUSICO", "RETRO-WAVE"),
filepath.Join("MUSICO", "edm"),
)
Expand All @@ -46,7 +46,7 @@ var _ = Describe("feature", Ordered, func() {
When("folders: wake and sleep", func() {
It("🧪 should: invoke inside hibernation range", Label("example"),
func(ctx SpecContext) {
path := helpers.Path(root, "RETRO-WAVE")
path := lab.Path(root, "RETRO-WAVE")
result, _ := tv.Walk().Configure().Extent(tv.Prime(
&tv.Using{
Root: path,
Expand Down Expand Up @@ -90,7 +90,7 @@ var _ = Describe("feature", Ordered, func() {

tv.WithHookQueryStatus(
func(qsys fs.StatFS, path string) (fs.FileInfo, error) {
return qsys.Stat(helpers.TrimRoot(path))
return qsys.Stat(lab.TrimRoot(path))
},
),

Expand All @@ -101,7 +101,7 @@ var _ = Describe("feature", Ordered, func() {
// using a different file system should not need to use
// this hook for this purpose.
//
return rsys.ReadDir(helpers.TrimRoot(dirname))
return rsys.ReadDir(lab.TrimRoot(dirname))
},
),
)).Navigate(ctx)
Expand All @@ -116,7 +116,7 @@ var _ = Describe("feature", Ordered, func() {

DescribeTable("simple hibernate",
func(ctx SpecContext, entry *hibernateTE) {
recording := make(helpers.RecordingMap)
recording := make(lab.RecordingMap)
once := func(node *tv.Node) error { //nolint:unparam // return nil error ok
_, found := recording[node.Extension.Name]
Expect(found).To(BeFalse())
Expand All @@ -125,7 +125,7 @@ var _ = Describe("feature", Ordered, func() {
return nil
}

path := helpers.Path(
path := lab.Path(
root,
lo.Ternary(entry.NaviTE.Relative == "",
"RETRO-WAVE",
Expand Down Expand Up @@ -173,18 +173,18 @@ var _ = Describe("feature", Ordered, func() {
tv.IfOption(entry.CaseSensitive, tv.WithHookCaseSensitiveSort()),
tv.WithHookQueryStatus(
func(qsys fs.StatFS, path string) (fs.FileInfo, error) {
return qsys.Stat(helpers.TrimRoot(path))
return qsys.Stat(lab.TrimRoot(path))
},
),

tv.WithHookReadDirectory(
func(rsys fs.ReadDirFS, dirname string) ([]fs.DirEntry, error) {
return rsys.ReadDir(helpers.TrimRoot(dirname))
return rsys.ReadDir(lab.TrimRoot(dirname))
},
),
)).Navigate(ctx)

helpers.AssertNavigation(&entry.NaviTE, &helpers.TestOptions{
lab.AssertNavigation(&entry.NaviTE, &lab.TestOptions{
FS: FS,
Recording: recording,
Path: path,
Expand All @@ -201,7 +201,7 @@ var _ = Describe("feature", Ordered, func() {
// === folders =======================================================

Entry(nil, &hibernateTE{
NaviTE: helpers.NaviTE{
NaviTE: lab.NaviTE{
Given: "wake and sleep (folders, inclusive:default)",
Relative: "RETRO-WAVE",
Subscription: enums.SubscribeFolders,
Expand All @@ -211,7 +211,7 @@ var _ = Describe("feature", Ordered, func() {
Prohibited: []string{"RETRO-WAVE", "Chromatics",
"Electric Youth", "Innerworld",
},
ExpectedNoOf: helpers.Quantities{
ExpectedNoOf: lab.Quantities{
Folders: 4,
},
},
Expand All @@ -234,7 +234,7 @@ var _ = Describe("feature", Ordered, func() {
}),

Entry(nil, &hibernateTE{
NaviTE: helpers.NaviTE{
NaviTE: lab.NaviTE{
Given: "wake and sleep (folders, excl:wake, inc:sleep, mute)",
Relative: "RETRO-WAVE",
Subscription: enums.SubscribeFolders,
Expand All @@ -244,7 +244,7 @@ var _ = Describe("feature", Ordered, func() {
Prohibited: []string{"Night Drive", "RETRO-WAVE",
"Chromatics", "Innerworld",
},
ExpectedNoOf: helpers.Quantities{
ExpectedNoOf: lab.Quantities{
Folders: 4,
},
},
Expand All @@ -268,15 +268,15 @@ var _ = Describe("feature", Ordered, func() {
}),

Entry(nil, &hibernateTE{
NaviTE: helpers.NaviTE{
NaviTE: lab.NaviTE{
Given: "wake only (folders, inclusive:default)",
Relative: "RETRO-WAVE",
Subscription: enums.SubscribeFolders,
Mandatory: []string{"Night Drive", "College", "Northern Council",
"Teenage Color", "Electric Youth", "Innerworld",
},
Prohibited: []string{"RETRO-WAVE", "Chromatics"},
ExpectedNoOf: helpers.Quantities{
ExpectedNoOf: lab.Quantities{
Folders: 6,
},
},
Expand All @@ -294,15 +294,15 @@ var _ = Describe("feature", Ordered, func() {
}),

Entry(nil, &hibernateTE{
NaviTE: helpers.NaviTE{
NaviTE: lab.NaviTE{
Given: "sleep only (folders, inclusive:default)",
Relative: "RETRO-WAVE",
Subscription: enums.SubscribeFolders,
Mandatory: []string{"RETRO-WAVE", "Chromatics", "Night Drive", "College",
"Northern Council", "Teenage Color",
},
Prohibited: []string{"Electric Youth", "Innerworld"},
ExpectedNoOf: helpers.Quantities{
ExpectedNoOf: lab.Quantities{
Folders: 6,
},
},
Expand All @@ -321,15 +321,15 @@ var _ = Describe("feature", Ordered, func() {
}),

Entry(nil, &hibernateTE{
NaviTE: helpers.NaviTE{
NaviTE: lab.NaviTE{
Given: "sleep only (folders, inclusive:default)",
Relative: "RETRO-WAVE",
Subscription: enums.SubscribeFolders,
Mandatory: []string{"RETRO-WAVE", "Chromatics"},
Prohibited: []string{"Night Drive", "College", "Northern Council",
"Teenage Color", "Electric Youth", "Innerworld",
},
ExpectedNoOf: helpers.Quantities{
ExpectedNoOf: lab.Quantities{
Folders: 2,
},
},
Expand Down
Loading
Loading