Monorepo for Tangled
tangled.org
1package knotacl
2
3import (
4 "context"
5 "path/filepath"
6 "testing"
7
8 "tangled.org/core/appview/db"
9)
10
11func TestLatchRoundTrip(t *testing.T) {
12 d, err := db.Make(context.Background(), filepath.Join(t.TempDir(), "appview.db"))
13 if err != nil {
14 t.Fatalf("db.Make: %v", err)
15 }
16
17 l := NewLatch(d, testLogger())
18
19 if l.IsNative("clam.nel.pet") {
20 t.Fatal("a fresh host must not read native through the adapter")
21 }
22
23 l.MarkNative("clam.nel.pet")
24
25 if !l.IsNative("clam.nel.pet") {
26 t.Fatal("a marked host must read back native through the adapter")
27 }
28 if l.IsNative("whelk.nel.pet") {
29 t.Fatal("an unmarked sibling must stay non-native")
30 }
31}