33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
//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())
|
|
}
|
|
}
|
|
}
|
|
}
|