| 1 |
// SPDX-License-Identifier: MPL-2.0 |
| 2 |
|
| 3 |
// Copyright (C) 2024-2025 Aleksa Sarai <[email protected]> |
| 4 |
// Copyright (C) 2024-2025 SUSE LLC |
| 5 |
// |
| 6 |
// This Source Code Form is subject to the terms of the Mozilla Public |
| 7 |
// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 8 |
// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 9 |
|
| 10 |
package testutils |
| 11 |
|
| 12 |
import ( |
| 13 |
"os" |
| 14 |
|
| 15 |
"github.com/stretchr/testify/require" |
| 16 |
) |
| 17 |
|
| 18 |
// Symlink is a wrapper around os.Symlink. |
| 19 |
func Symlink(t TestingT, oldname, newname string) { |
| 20 |
err := os.Symlink(oldname, newname) |
| 21 |
require.NoError(t, err) |
| 22 |
} |
| 23 |
|
| 24 |
// MkdirAll is a wrapper around os.MkdirAll. |
| 25 |
func MkdirAll(t TestingT, path string, mode os.FileMode) { //nolint:unparam // wrapper func |
| 26 |
err := os.MkdirAll(path, mode) |
| 27 |
require.NoError(t, err) |
| 28 |
} |
| 29 |
|
| 30 |
// WriteFile is a wrapper around os.WriteFile. |
| 31 |
func WriteFile(t TestingT, path string, data []byte, mode os.FileMode) { |
| 32 |
err := os.WriteFile(path, data, mode) |
| 33 |
require.NoError(t, err) |
| 34 |
} |