mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
57 lines
994 B
Go
57 lines
994 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestFileExists(t *testing.T) {
|
|
fileName := "missing"
|
|
if x, _ := fileExists(fileName); x {
|
|
t.Fatalf("file %v doesn't exist", fileName)
|
|
}
|
|
file, err := os.Create(fileName)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
file.Close()
|
|
|
|
if x, _ := fileExists(fileName); !x {
|
|
t.Fatalf("file %v doesn't exist", fileName)
|
|
}
|
|
|
|
t.Cleanup(func() {
|
|
os.Remove(fileName)
|
|
})
|
|
}
|
|
|
|
func TestMainProgram(t *testing.T) {
|
|
os.Args = []string{
|
|
"roaring-migrate",
|
|
"--verbose",
|
|
}
|
|
if realMain() == 0 {
|
|
t.Fatal("should fail and it succeeded")
|
|
}
|
|
os.Args = []string{
|
|
"roaring-migrate",
|
|
"--verbose",
|
|
}
|
|
if realMain() == 0 {
|
|
t.Fatal("should fail and it succeeded")
|
|
}
|
|
dir, err := os.MkdirTemp("", "backup")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer os.RemoveAll(dir) // clean up
|
|
os.Args = []string{
|
|
"roaring-migrate",
|
|
"--verbose=true",
|
|
"--data-dir=testdata/data-dir/",
|
|
"--backup-dir=" + dir,
|
|
}
|
|
if realMain() == 1 {
|
|
t.Fatal("shouldn't fail")
|
|
}
|
|
}
|