math-optim/algo/util_test.go
surtur c1f986860e
All checks were successful
continuous-integration/drone/push Build is passing
go(algo): properly clean up in util_test.go
2022-07-08 22:11:30 +02:00

44 lines
974 B
Go

// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package algo
import (
"os"
"testing"
)
// nolint: ifshort
func TestCreateFolder(t *testing.T) {
// let's assume this will never exist in a clean project...
testPath := "whatever-path"
got := createFolder(testPath)
var want error
if want != got {
t.Errorf("issue creating folder, testPath: %q, full cmd: %q", testPath, got.Error())
}
os.RemoveAll(testPath)
}
// nolint: ifshort
func TestCreatePath(t *testing.T) {
// let's assume this, too, will never exist in a clean project...
testPathRoot := "whatever-path"
testPath := testPathRoot + "/whatever-subpath/subsubpath"
got := createPath(testPath)
var want error
if want != got {
t.Errorf("issue creating folders in path, testPath: %q, full cmd: %q", testPath, got.Error())
}
// clean up from the root.
if err := os.RemoveAll(testPathRoot); err != nil {
t.Error("error cleaning up: ", err)
}
}