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(feat): use shared test code (#158)
- Loading branch information
1 parent
b471989
commit 94ff8ae
Showing
5 changed files
with
59 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package sampling_test | ||
|
||
import ( | ||
"io/fs" | ||
"path/filepath" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok | ||
. "github.com/onsi/gomega" //nolint:revive // ok | ||
"github.com/snivilised/traverse/enums" | ||
"github.com/snivilised/traverse/internal/filtering" | ||
) | ||
|
||
func TestSampling(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Sampling Suite") | ||
} | ||
|
||
// customSamplingFilter is a custom sampling filter that just happens | ||
// to use a glob as part of its implementation. The client can of course | ||
// define their own custom implementation using filter.SampleFilter. | ||
type customSamplingFilter struct { | ||
filtering.Sample | ||
description string | ||
pattern string | ||
} | ||
|
||
func (f *customSamplingFilter) Description() string { | ||
return f.description | ||
} | ||
|
||
func (f *customSamplingFilter) Scope() enums.FilterScope { | ||
return f.Sample.Scope() | ||
} | ||
|
||
func (f *customSamplingFilter) Matching(children []fs.DirEntry) []fs.DirEntry { | ||
return f.Sample.Matching(children, | ||
func(entry fs.DirEntry, _ int) bool { | ||
matched, _ := filepath.Match(f.pattern, entry.Name()) | ||
return matched | ||
}, | ||
) | ||
} |
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
Oops, something went wrong.