@@ -2000,12 +2000,30 @@ func TestResolveScriptPaths(t *testing.T) {
20002000 dir := t .TempDir ()
20012001 require .NoError (t , os .WriteFile (filepath .Join (dir , "a.sh" ), []byte ("#!/bin/bash" ), 0o644 ))
20022002 require .NoError (t , os .WriteFile (filepath .Join (dir , "b.sh" ), []byte ("#!/bin/bash" ), 0o644 ))
2003+
2004+ items := []fleet.BaseItem {{Paths : ptr .String ("*.sh" )}} //nolint:modernize
2005+ result , errs := resolveScriptPaths (items , dir , nopLogf )
2006+ require .Empty (t , errs )
2007+ require .Len (t , result , 2 )
2008+ })
2009+
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 ))
20032015 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 ))
20042017
20052018 items := []fleet.BaseItem {{Paths : ptr .String ("*" )}} //nolint:modernize
20062019 result , errs := resolveScriptPaths (items , dir , nopLogf )
20072020 require .Empty (t , errs )
20082021 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 )
20092027 })
20102028
20112029 t .Run ("inline_not_allowed" , func (t * testing.T ) {
0 commit comments