Skip to content

Commit

Permalink
random file for RoundTripFileWithNoSheetCols test
Browse files Browse the repository at this point in the history
In my test, RoundTripFileWithNoSheetCols  fails with error
`e"remove testdocs/after_write.xlsx: no such file or directory"`
This is most likely due to the parallel test runs called by csRunO
that try to write and remove the files concurrently.

By choosing a random filename,
each test create/write and removes its own file,
the test passed as expected.
  • Loading branch information
benedictjohannes committed Sep 9, 2023
1 parent c8a49a6 commit baa8cb3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package xlsx
import (
"bytes"
"encoding/xml"
"math/rand"
"os"
"strconv"
"strings"
"testing"

Expand Down Expand Up @@ -1357,11 +1359,12 @@ func TestLib(t *testing.T) {
csRunO(c, "RoundTripFileWithNoSheetCols", func(c *qt.C, option FileOption) {
originalXlFile, err := OpenFile("testdocs/original.xlsx", option)
c.Assert(err, qt.IsNil)
err = originalXlFile.Save("testdocs/after_write.xlsx")
destFile := "testdocs/" + strconv.Itoa(rand.Int()) + ".xlsx"
err = originalXlFile.Save(destFile)
c.Assert(err, qt.IsNil)
_, err = OpenFile("testdocs/after_write.xlsx", option)
_, err = OpenFile(destFile)
c.Assert(err, qt.IsNil)
err = os.Remove("testdocs/after_write.xlsx")
err = os.Remove(destFile)
c.Assert(err, qt.IsNil)
})

Expand Down

0 comments on commit baa8cb3

Please sign in to comment.