26 lines
549 B
Go
26 lines
549 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestInit(t *testing.T) {
|
|
t.Run("CreatesDatabase", func(t *testing.T) {
|
|
env := &testEnv{t: t, dir: t.TempDir(), user: "testuser"}
|
|
env.mustAx("init")
|
|
if _, err := os.Stat(filepath.Join(env.dir, ".ax", "ax.db")); err != nil {
|
|
t.Fatal(".ax/ax.db not created")
|
|
}
|
|
})
|
|
|
|
t.Run("FailsIfAlreadyExists", func(t *testing.T) {
|
|
env := newTestEnv(t, "testuser")
|
|
_, err := env.ax("init")
|
|
if err == nil {
|
|
t.Fatal("expected error re-initialising existing DB, got none")
|
|
}
|
|
})
|
|
}
|