emptyJavaScriptFile returns a callable function to create an empty file on the disk and returns a teardown function to remove the file after its use.
(t *testing.T)
| 1613 | // emptyJavaScriptFile returns a callable function to create an empty file on the disk |
| 1614 | // and returns a teardown function to remove the file after its use. |
| 1615 | func emptyJavaScriptFile(t *testing.T) func() (path string, teardownFn func()) { |
| 1616 | return func() (path string, teardownFn func()) { |
| 1617 | file, err := os.CreateTemp("", "*.js") |
| 1618 | require.NoError(t, err, "Error creating JavaScript file") |
| 1619 | path = file.Name() |
| 1620 | teardownFn = func() { |
| 1621 | assert.NoError(t, file.Close(), "Error closing file: %s ", path) |
| 1622 | assert.NoError(t, os.Remove(path), "Error removing file: %s ", path) |
| 1623 | assert.False(t, base.FileExists(path), "File %s should be removed", path) |
| 1624 | } |
| 1625 | return path, teardownFn |
| 1626 | } |
| 1627 | } |
| 1628 | |
| 1629 | // missingJavaScriptFile returns a callable function that internally returns a missing |
| 1630 | // JavaScript file path. The callable teardown function returned from this function is nil. |
no test coverage detected