2021-11-01 00:24:26 +00:00
|
|
|
//stm: #unit
|
2019-07-10 15:10:45 +00:00
|
|
|
package repo
|
|
|
|
|
2019-07-18 14:01:39 +00:00
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
2019-07-10 15:10:45 +00:00
|
|
|
|
|
|
|
func genFsRepo(t *testing.T) (*FsRepo, func()) {
|
2019-07-18 14:01:39 +00:00
|
|
|
path, err := ioutil.TempDir("", "lotus-repo-")
|
2019-07-10 15:10:45 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
repo, err := NewFS(path)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-07-18 14:01:39 +00:00
|
|
|
|
2019-11-12 17:59:38 +00:00
|
|
|
err = repo.Init(FullNode)
|
2019-07-18 14:01:39 +00:00
|
|
|
if err != ErrRepoExists && err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-07-10 15:10:45 +00:00
|
|
|
return repo, func() {
|
2019-07-10 15:14:29 +00:00
|
|
|
_ = os.RemoveAll(path)
|
2019-07-10 15:10:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFsBasic(t *testing.T) {
|
|
|
|
repo, closer := genFsRepo(t)
|
|
|
|
defer closer()
|
|
|
|
basicTest(t, repo)
|
|
|
|
}
|