mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-08-13 22:37:28 +00:00
fix(sites): remove stale domain links on sync (#110)
This commit is contained in:
parent
b48608c4e9
commit
bf777a1475
2 changed files with 41 additions and 0 deletions
|
|
@ -111,6 +111,31 @@ func TestManagerAddRemoveSyncAsk(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSyncRemovesStaleDomainEntries(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
st, err := store.Open(filepath.Join(dir, "test.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer st.Close()
|
||||
|
||||
m, err := NewManager(st, dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
stale := filepath.Join(dir, "domains", "stale.example.com")
|
||||
if err := os.WriteFile(stale, []byte("stale"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := m.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Lstat(stale); !os.IsNotExist(err) {
|
||||
t.Errorf("expected stale domain entry removed, got err=%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAskUserSubdomain(t *testing.T) {
|
||||
t.Setenv("AGENTBBS_HOST", "bbs.profullstack.com")
|
||||
dir := t.TempDir()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue