CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755
(t testing.TB, sourceFile string, destinationFile string)
| 245 | |
| 246 | // CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755 |
| 247 | func CopyFile(t testing.TB, sourceFile string, destinationFile string) { |
| 248 | t.Helper() |
| 249 | |
| 250 | src, err := os.Open(sourceFile) |
| 251 | assert.NilError(t, err, "Failed to open source file: %s") |
| 252 | //nolint:errcheck |
| 253 | defer src.Close() |
| 254 | |
| 255 | dst, err := os.OpenFile(destinationFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755) |
| 256 | assert.NilError(t, err, "Failed to open destination file: %s", destinationFile) |
| 257 | //nolint:errcheck |
| 258 | defer dst.Close() |
| 259 | |
| 260 | _, err = io.Copy(dst, src) |
| 261 | assert.NilError(t, err, "Failed to copy file: %s", sourceFile) |
| 262 | } |
| 263 | |
| 264 | // BaseEnvironment provides the minimal environment variables used across all |
| 265 | // Docker / Compose commands. |