Fix Windows tests, verify in CI (#394)

* ci: Test on Windows too

Adds a Windows test run to CI.
Go setup relies on GHA for this
because Hermit doesn't yet support Windows.

* fix(mapper_windows_test): assert.NotNil => assert.True

assert.NotNil does not exist.

* filecontent mapper: Handle error from directory

If we couldn't read because the source is a directory,
override the original error message.

* fix(test): Handle platform-specific "file not found" messages
This commit is contained in:
Abhinav Gupta
2023-12-09 20:42:50 -08:00
committed by GitHub
parent 815ba68265
commit 3263463a7e
6 changed files with 51 additions and 28 deletions
+3 -2
View File
@@ -33,11 +33,12 @@ func TestWindowsFileMapper(t *testing.T) {
p := mustNew(t, &cli)
_, err := p.Parse([]string{"testdata\\file.txt"})
assert.NoError(t, err)
assert.NotNil(t, cli.File)
assert.True(t, cli.File != nil, "File should not be nil")
_ = cli.File.Close()
_, err = p.Parse([]string{"testdata\\missing.txt"})
assert.Error(t, err)
assert.Contains(t, err.Error(), "missing.txt: The system cannot find the file specified.")
assert.Contains(t, err.Error(), "missing.txt:")
assert.IsError(t, err, os.ErrNotExist)
_, err = p.Parse([]string{"-"})
assert.NoError(t, err)
assert.Equal(t, os.Stdin, cli.File)