Use Go rules for Windows filename components
This commit is contained in:
32
internal/engine/discovery_windows_test.go
Normal file
32
internal/engine/discovery_windows_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
//go:build windows
|
||||
|
||||
package engine
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWindowsSearchRejectsReservedComponentsBeforeAcquisition(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
root := t.TempDir()
|
||||
first := writeImportFile(t, root, "first.yml", "value: first\n")
|
||||
for _, name := range []string{"CONIN$", "CONOUT$"} {
|
||||
for _, source := range []Source{
|
||||
SearchConfig(name, Searches(Paths(first), WorkingDirectory())),
|
||||
SearchConfig("", Searches(Paths(first), SearchDirectory(root, DirectorySearchOptions{
|
||||
Filenames: []FilenameGroup{CustomFilenames(name)},
|
||||
}))),
|
||||
} {
|
||||
result, err := testLoad[discoveryLoadConfig](source, Options[discoveryLoadConfig]{})
|
||||
var failure *LoadError
|
||||
if result != nil || !errors.As(err, &failure) || len(failure.Diagnostics()) != 1 || failure.Diagnostics()[0].Code != CodeOptionsInvalid {
|
||||
t.Fatalf("reserved component %q accepted: %#v, %v", name, result, err)
|
||||
}
|
||||
if len(failure.Sources()) != 0 {
|
||||
t.Fatalf("reserved component %q was checked after acquisition: %#v", name, failure.Sources())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user