Tests for msfr

License: MIT
Signed-off-by: Zander Mackie <zmackie@gmail.com>
This commit is contained in:
Zander Mackie 2017-01-20 15:58:55 -05:00
parent 4028e89016
commit eb5ba9d761

View File

@ -0,0 +1,33 @@
package mfsr
import (
"io/ioutil"
"testing"
"github.com/ipfs/go-ipfs/thirdparty/assert"
)
func testVersionFile(v string, t *testing.T) (rp RepoPath) {
name, err := ioutil.TempDir("", v)
if err != nil {
t.Fatal(err)
}
rp = RepoPath(name)
return rp
}
func TestVersion(t *testing.T) {
rp := RepoPath("")
_, err := rp.Version()
assert.Err(err, t, "Should throw an error when path is bad,")
rp = testVersionFile("4", t)
_, err = rp.Version()
assert.Err(err, t, "Bad VersionFile")
assert.Nil(rp.WriteVersion(4), t, "Trouble writing version")
assert.Nil(rp.CheckVersion(4), t, "Trouble checking the verion")
assert.Err(rp.CheckVersion(1), t, "Should throw an error for the wrong version.")
}