WithRandomHomeDir sets CF_HOME and CF_PLUGIN_HOME to a temp directory and outputs the created directory through GinkgoWriter. Then it executes the provided function 'action'. Finally, it’s restoring the previous CF_HOME and CF_PLUGIN_HOME.
(action func())
| 41 | // the created directory through GinkgoWriter. Then it executes the provided function |
| 42 | // 'action'. Finally, it’s restoring the previous CF_HOME and CF_PLUGIN_HOME. |
| 43 | func WithRandomHomeDir(action func()) { |
| 44 | oldHomeDir, oldPluginHomeDir := getHomeDirs() |
| 45 | homeDir := SetHomeDir() |
| 46 | action() |
| 47 | setHomeDirsTo(oldHomeDir, oldPluginHomeDir) |
| 48 | DestroyHomeDir(homeDir) |
| 49 | } |
| 50 | |
| 51 | func getHomeDirs() (string, string) { |
| 52 | homeDir := os.Getenv("CF_HOME") |
no test coverage detected