@@ -2007,6 +2007,25 @@ func TestResolveScriptPaths(t *testing.T) {
20072007 require .Len (t , result , 2 )
20082008 })
20092009
2010+ t .Run ("glob_filters_non_script_extensions" , func (t * testing.T ) {
2011+ t .Parallel ()
2012+ dir := t .TempDir ()
2013+ require .NoError (t , os .WriteFile (filepath .Join (dir , "a.sh" ), []byte ("#!/bin/bash" ), 0o644 ))
2014+ require .NoError (t , os .WriteFile (filepath .Join (dir , "b.ps1" ), []byte ("Write-Host" ), 0o644 ))
2015+ require .NoError (t , os .WriteFile (filepath .Join (dir , "c.py" ), []byte ("#!/usr/bin/env python3" ), 0o644 ))
2016+ require .NoError (t , os .WriteFile (filepath .Join (dir , "d.txt" ), []byte ("not a script" ), 0o644 ))
2017+
2018+ items := []fleet.BaseItem {{Paths : ptr .String ("*" )}} //nolint:modernize
2019+ result , errs := resolveScriptPaths (items , dir , nopLogf )
2020+ require .Empty (t , errs )
2021+ require .Len (t , result , 3 )
2022+ got := make ([]string , 0 , len (result ))
2023+ for _ , r := range result {
2024+ got = append (got , filepath .Base (* r .Path ))
2025+ }
2026+ assert .Equal (t , []string {"a.sh" , "b.ps1" , "c.py" }, got )
2027+ })
2028+
20102029 t .Run ("inline_not_allowed" , func (t * testing.T ) {
20112030 t .Parallel ()
20122031 items := []fleet.BaseItem {{}}
0 commit comments