MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / emptyJavaScriptFile

Function emptyJavaScriptFile

rest/config_test.go:1615–1627  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
1615func 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.

Calls 4

FileExistsFunction · 0.92
NameMethod · 0.65
CloseMethod · 0.65
RemoveMethod · 0.65

Tested by

no test coverage detected