c229842f57
The directory created by `T.TempDir` is automatically removed when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
27 lines
352 B
Go
27 lines
352 B
Go
//stm: #unit
|
|
package repo
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func genFsRepo(t *testing.T) *FsRepo {
|
|
path := t.TempDir()
|
|
|
|
repo, err := NewFS(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
err = repo.Init(FullNode)
|
|
if err != ErrRepoExists && err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return repo
|
|
}
|
|
|
|
func TestFsBasic(t *testing.T) {
|
|
repo := genFsRepo(t)
|
|
basicTest(t, repo)
|
|
}
|