This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / appview / db / repos_test.go
1.3 kB 47 lines
1package db 2 3import ( 4 "context" 5 "path/filepath" 6 "testing" 7 8 "tangled.org/core/appview/models" 9) 10 11func TestMakeReopenPreservesOrphanData(t *testing.T) { 12 path := filepath.Join(t.TempDir(), "reopen.db") 13 14 d, err := Make(context.Background(), path) 15 if err != nil { 16 t.Fatalf("first Make: %v", err) 17 } 18 19 repo := seedRepo(t, d, "did:plc:akshay", "ghost.example", "anemone", "anemone", "did:plc:anemone") 20 notif := &models.Notification{ 21 RecipientDid: "did:plc:akshay", 22 ActorDid: "did:plc:boltless", 23 Type: models.NotificationTypeRepoStarred, 24 EntityType: "repo", 25 EntityId: repo.RepoAt().String(), 26 RepoId: &repo.Id, 27 } 28 if err := CreateNotification(d, notif); err != nil { 29 t.Fatalf("CreateNotification: %v", err) 30 } 31 if err := d.Close(); err != nil { 32 t.Fatalf("Close: %v", err) 33 } 34 35 d2, err := Make(context.Background(), path) 36 if err != nil { 37 t.Fatalf("second Make: %v", err) 38 } 39 t.Cleanup(func() { d2.Close() }) 40 41 if got := countRows(t, d2, "select count(*) from repos where knot = ?", "ghost.example"); got != 1 { 42 t.Errorf("orphan repo lost across reopen: got %d, want 1", got) 43 } 44 if got := countRows(t, d2, "select count(*) from notifications"); got != 1 { 45 t.Errorf("notification lost across reopen: got %d, want 1", got) 46 } 47}