You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
826 B

package main
import (
"os"
"path/filepath"
"testing"
)
func TestLegacyFrontendDatabaseResetIncludesSQLiteSidecars(t *testing.T) {
root := t.TempDir()
path := filepath.Join(root, "frontend.db")
for _, suffix := range []string{"", "-wal", "-shm", "-journal"} {
if err := os.WriteFile(path+suffix, []byte("customer-data"), 0600); err != nil {
t.Fatal(err)
}
}
other := filepath.Join(root, "unrelated")
if err := os.WriteFile(other, []byte("keep"), 0600); err != nil {
t.Fatal(err)
}
if err := removeLegacyDatabase(path); err != nil {
t.Fatal(err)
}
for _, suffix := range []string{"", "-wal", "-shm", "-journal"} {
if _, err := os.Stat(path + suffix); !os.IsNotExist(err) {
t.Fatal("SQLite state survived")
}
}
if _, err := os.Stat(other); err != nil {
t.Fatal("unrelated file removed")
}
}