Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
32 lines
651 B
Go
32 lines
651 B
Go
package xos_test
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/ignite/cli/v29/ignite/pkg/xos"
|
|
)
|
|
|
|
func TestRename(t *testing.T) {
|
|
var (
|
|
dir = t.TempDir()
|
|
oldpath = path.Join(dir, "old")
|
|
newpath = path.Join(dir, "new")
|
|
require = require.New(t)
|
|
)
|
|
err := os.WriteFile(oldpath, []byte("foo"), os.ModePerm)
|
|
require.NoError(err)
|
|
|
|
err = xos.Rename(oldpath, newpath)
|
|
|
|
require.NoError(err)
|
|
bz, err := os.ReadFile(newpath)
|
|
require.NoError(err)
|
|
require.Equal([]byte("foo"), bz)
|
|
_, err = os.Open(oldpath)
|
|
require.EqualError(err, fmt.Sprintf("open %s: no such file or directory", oldpath))
|
|
}
|