43 lines
768 B
Go
Executable File
43 lines
768 B
Go
Executable File
package versions
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"gitea.inhome.blapointe.com/local/notes-server/config"
|
|
"os"
|
|
"path"
|
|
"testing"
|
|
)
|
|
|
|
func TestVersions(t *testing.T) {
|
|
d, err := ioutil.TempDir(os.TempDir(), "prefix")
|
|
config.Root = d
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, f := range []string{"a", "b"} {
|
|
ioutil.WriteFile(path.Join(d, f+".md"), []byte(f), os.ModePerm)
|
|
}
|
|
|
|
v, err := New()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := v.AddAll(); err != nil {
|
|
t.Error(err)
|
|
}
|
|
if err := v.Commit(); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if err := v.Gitmmit(); err == nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
for _, f := range []string{"c", "b"} {
|
|
ioutil.WriteFile(path.Join(d, f+".md"), []byte("d"), os.ModePerm)
|
|
}
|
|
if err := v.Gitmmit(); err != nil {
|
|
t.Error(config.Root, err)
|
|
}
|
|
}
|