mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-27 03:58:06 +00:00
6d074a96e9
Simplify things, drop TempFile at the same time (refs. #1764)
30 lines
713 B
Go
30 lines
713 B
Go
package io
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMakeDirForFile_HappyPath(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
filePath := path.Join(tempDir, "testDir/testFile.test")
|
|
err := MakeDirForFile(filePath, "test")
|
|
require.NoError(t, err)
|
|
|
|
_, errChDir := os.Create(filePath)
|
|
require.NoError(t, errChDir)
|
|
}
|
|
|
|
func TestMakeDirForFile_Negative(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
filePath := path.Join(tempDir, "testFile.test")
|
|
_, err := os.Create(filePath)
|
|
require.NoError(t, err)
|
|
|
|
filePath = path.Join(filePath, "error")
|
|
err = MakeDirForFile(filePath, "test")
|
|
require.Errorf(t, err, "could not create dir for test: mkdir %s : not a directory", filePath)
|
|
}
|