mirror of
https://github.com/dagu-org/dagu.git
synced 2025-12-28 06:34:22 +00:00
fix(store): exact match for DAG name lookup in listRoot (#1490)
* **Bug Fixes** * Fixed filtering logic for DAG runs to require exact name matching instead of substring matching, refining which results are returned when filtering is applied.
This commit is contained in:
parent
c72623154d
commit
eef457b4c2
@ -500,7 +500,7 @@ func (store *Store) listRoot(_ context.Context, include string) ([]DataRoot, err
|
|||||||
|
|
||||||
var roots []DataRoot
|
var roots []DataRoot
|
||||||
for _, dir := range rootDirs {
|
for _, dir := range rootDirs {
|
||||||
if include != "" && !strings.Contains(dir, include) {
|
if include != "" && dir != include {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if fileutil.IsDir(filepath.Join(store.baseDir, dir)) {
|
if fileutil.IsDir(filepath.Join(store.baseDir, dir)) {
|
||||||
|
|||||||
@ -314,6 +314,22 @@ func TestListRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestListRootExactMatch verifies that listRoot does exact matching, not substring matching.
|
||||||
|
// Regression test for issue #1473.
|
||||||
|
func TestListRootExactMatch(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir, "go"), 0750))
|
||||||
|
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir, "go_fasthttp"), 0750))
|
||||||
|
|
||||||
|
store := &Store{baseDir: tmpDir}
|
||||||
|
roots, err := store.listRoot(context.Background(), "go")
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, roots, 1, "should only match 'go', not 'go_fasthttp'")
|
||||||
|
assert.Equal(t, "go", roots[0].prefix)
|
||||||
|
}
|
||||||
|
|
||||||
func TestListRootEmptyDirectory(t *testing.T) {
|
func TestListRootEmptyDirectory(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user