(t *testing.T)
| 1545 | } |
| 1546 | |
| 1547 | func TestEventMasks(t *testing.T) { |
| 1548 | t.Parallel() |
| 1549 | |
| 1550 | cfg := newMockedConfig() |
| 1551 | defSub := new(eventmocks.BufferedSubscription) |
| 1552 | diskSub := new(eventmocks.BufferedSubscription) |
| 1553 | mdb, err := sqlite.Open(t.TempDir()) |
| 1554 | if err != nil { |
| 1555 | t.Fatal(err) |
| 1556 | } |
| 1557 | t.Cleanup(func() { |
| 1558 | mdb.Close() |
| 1559 | }) |
| 1560 | kdb := db.NewMiscDB(mdb) |
| 1561 | svc := New(protocol.LocalDeviceID, cfg, "", "syncthing", nil, defSub, diskSub, events.NoopLogger, nil, nil, nil, nil, nil, nil, false, kdb).(*service) |
| 1562 | |
| 1563 | if mask := svc.getEventMask(""); mask != DefaultEventMask { |
| 1564 | t.Errorf("incorrect default mask %x != %x", int64(mask), int64(DefaultEventMask)) |
| 1565 | } |
| 1566 | |
| 1567 | expected := events.FolderSummary | events.LocalChangeDetected |
| 1568 | if mask := svc.getEventMask("FolderSummary,LocalChangeDetected"); mask != expected { |
| 1569 | t.Errorf("incorrect parsed mask %x != %x", int64(mask), int64(expected)) |
| 1570 | } |
| 1571 | |
| 1572 | expected = 0 |
| 1573 | if mask := svc.getEventMask("WeirdEvent,something else that doesn't exist"); mask != expected { |
| 1574 | t.Errorf("incorrect parsed mask %x != %x", int64(mask), int64(expected)) |
| 1575 | } |
| 1576 | |
| 1577 | if res := svc.getEventSub(DefaultEventMask); res != defSub { |
| 1578 | t.Errorf("should have returned the given default event sub") |
| 1579 | } |
| 1580 | if res := svc.getEventSub(DiskEventMask); res != diskSub { |
| 1581 | t.Errorf("should have returned the given disk event sub") |
| 1582 | } |
| 1583 | if res := svc.getEventSub(events.LocalIndexUpdated); res == nil || res == defSub || res == diskSub { |
| 1584 | t.Errorf("should have returned a valid, non-default event sub") |
| 1585 | } |
| 1586 | } |
| 1587 | |
| 1588 | func TestBrowse(t *testing.T) { |
| 1589 | t.Parallel() |
nothing calls this directly
no test coverage detected