From 31241e0d6bf5f8147dd490da91c85c91f22f3322 Mon Sep 17 00:00:00 2001 From: plastikfan Date: Wed, 11 Oct 2023 09:08:05 +0100 Subject: [PATCH] feat(nav): add format to session started at (#338) --- xfs/nav/navigation-async_test.go | 2 +- xfs/nav/navigation-listener_test.go | 8 ++++---- xfs/nav/navigation-session.go | 9 +++++++-- xfs/nav/navigation-with-runner_test.go | 2 +- xfs/nav/resume-strategy_test.go | 2 +- xfs/nav/traverse-navigator-error_test.go | 14 +++++++------- xfs/nav/traverse-navigator-scope_test.go | 2 +- xfs/nav/traverse-navigator-skip_test.go | 6 +++--- xfs/nav/traverse-navigator-sort_test.go | 2 +- xfs/nav/traverse-navigator-subpath_test.go | 6 +++--- xfs/nav/traverse-navigator_test.go | 3 ++- 11 files changed, 31 insertions(+), 25 deletions(-) diff --git a/xfs/nav/navigation-async_test.go b/xfs/nav/navigation-async_test.go index a474d53..b55e014 100644 --- a/xfs/nav/navigation-async_test.go +++ b/xfs/nav/navigation-async_test.go @@ -211,7 +211,7 @@ var _ = Describe("navigation", Ordered, func() { } wgan.Wait("👾 test-main") - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() if consumer != nil { diff --git a/xfs/nav/navigation-listener_test.go b/xfs/nav/navigation-listener_test.go index f486d6b..4dd2ea6 100644 --- a/xfs/nav/navigation-listener_test.go +++ b/xfs/nav/navigation-listener_test.go @@ -81,7 +81,7 @@ var _ = Describe("Listener", Ordered, func() { reason := fmt.Sprintf("❌ remaining: '%v'", strings.Join(entry.mandatory, ", ")) Expect(len(entry.mandatory)).To(Equal(0), reason) - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }, func(entry *listenTE) string { @@ -237,7 +237,7 @@ var _ = Describe("Listener", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) @@ -266,7 +266,7 @@ var _ = Describe("Listener", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -346,7 +346,7 @@ var _ = Describe("Listener", Ordered, func() { files, folders, ) - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) diff --git a/xfs/nav/navigation-session.go b/xfs/nav/navigation-session.go index 22b69d2..4f267dc 100644 --- a/xfs/nav/navigation-session.go +++ b/xfs/nav/navigation-session.go @@ -7,7 +7,8 @@ import ( ) type Session interface { - StartedAt() time.Time + StartedAtTime() time.Time + StartedAt(format string) string Elapsed() time.Duration } @@ -24,10 +25,14 @@ type session struct { duration time.Duration } -func (s *session) StartedAt() time.Time { +func (s *session) StartedAtTime() time.Time { return s.startAt } +func (s *session) StartedAt(format string) string { + return s.startAt.Format(format) +} + func (s *session) Elapsed() time.Duration { return s.duration } diff --git a/xfs/nav/navigation-with-runner_test.go b/xfs/nav/navigation-with-runner_test.go index beeb843..c1d7ffb 100644 --- a/xfs/nav/navigation-with-runner_test.go +++ b/xfs/nav/navigation-with-runner_test.go @@ -97,7 +97,7 @@ var _ = Describe("NavigationWithRunner", Ordered, func() { } Expect(err).Error().To(BeNil()) - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) diff --git a/xfs/nav/resume-strategy_test.go b/xfs/nav/resume-strategy_test.go index 2e888f5..4b943c7 100644 --- a/xfs/nav/resume-strategy_test.go +++ b/xfs/nav/resume-strategy_test.go @@ -303,7 +303,7 @@ var _ = Describe("Resume", Ordered, func() { folders: result.Metrics.Count(nav.MetricNoFoldersInvokedEn), } - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() } diff --git a/xfs/nav/traverse-navigator-error_test.go b/xfs/nav/traverse-navigator-error_test.go index 60c875f..0243ab1 100644 --- a/xfs/nav/traverse-navigator-error_test.go +++ b/xfs/nav/traverse-navigator-error_test.go @@ -140,7 +140,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) @@ -161,7 +161,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -219,7 +219,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -256,7 +256,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -287,7 +287,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { fmt.Sprintf("❌ expected error to be path not found, but was: '%v'", err), ) - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -315,7 +315,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { Expect(query).To(BeTrue(), fmt.Sprintf("❌ expected error to be path not found, but was: '%v'", err), ) - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -349,7 +349,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { fmt.Sprintf("❌ expected error to be path not found, but was: '%v'", err), ) - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) diff --git a/xfs/nav/traverse-navigator-scope_test.go b/xfs/nav/traverse-navigator-scope_test.go index a26c59f..bd6abf1 100644 --- a/xfs/nav/traverse-navigator-scope_test.go +++ b/xfs/nav/traverse-navigator-scope_test.go @@ -59,7 +59,7 @@ var _ = Describe("TraverseNavigatorScope", Ordered, func() { Expect(actual).To(Equal(expected), helpers.Reason(name)) } - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }, func(entry *scopeTE) string { diff --git a/xfs/nav/traverse-navigator-skip_test.go b/xfs/nav/traverse-navigator-skip_test.go index 9f91664..b6c474b 100644 --- a/xfs/nav/traverse-navigator-skip_test.go +++ b/xfs/nav/traverse-navigator-skip_test.go @@ -40,7 +40,7 @@ var _ = Describe("TraverseNavigatorSkip", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -60,7 +60,7 @@ var _ = Describe("TraverseNavigatorSkip", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -80,7 +80,7 @@ var _ = Describe("TraverseNavigatorSkip", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }, func(entry *skipTE) string { diff --git a/xfs/nav/traverse-navigator-sort_test.go b/xfs/nav/traverse-navigator-sort_test.go index 71187d9..41866f0 100644 --- a/xfs/nav/traverse-navigator-sort_test.go +++ b/xfs/nav/traverse-navigator-sort_test.go @@ -75,7 +75,7 @@ var _ = Describe("TraverseNavigatorSort", Ordered, func() { sequence = recording[n] } - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }, func(entry *sortTE) string { diff --git a/xfs/nav/traverse-navigator-subpath_test.go b/xfs/nav/traverse-navigator-subpath_test.go index 84aeddf..e43cb66 100644 --- a/xfs/nav/traverse-navigator-subpath_test.go +++ b/xfs/nav/traverse-navigator-subpath_test.go @@ -60,7 +60,7 @@ var _ = Describe("TraverseNavigatorSubpath", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) @@ -100,7 +100,7 @@ var _ = Describe("TraverseNavigatorSubpath", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) @@ -140,7 +140,7 @@ var _ = Describe("TraverseNavigatorSubpath", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAtTime() _ = result.Session.Elapsed() }) }) diff --git a/xfs/nav/traverse-navigator_test.go b/xfs/nav/traverse-navigator_test.go index cb80b5e..7a5c14a 100644 --- a/xfs/nav/traverse-navigator_test.go +++ b/xfs/nav/traverse-navigator_test.go @@ -5,6 +5,7 @@ import ( "io/fs" "path/filepath" "strings" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -67,7 +68,7 @@ var _ = Describe("TraverseNavigator(logged)", Ordered, func() { OptionsFn: optionFn, }).Run() - _ = result.Session.StartedAt() + _ = result.Session.StartedAt(time.RFC1123) _ = result.Session.Elapsed() if entry.visit {