forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory_layer_decode_test.dart
More file actions
70 lines (62 loc) · 2.12 KB
/
Copy pathmemory_layer_decode_test.dart
File metadata and controls
70 lines (62 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import 'package:flutter_test/flutter_test.dart';
import 'package:omi/backend/schema/memory.dart';
void main() {
group('MemoryLayer decode', () {
test('layer field only sets explicit layer', () {
final memory = Memory.fromJson({
'id': 'mem-layer-1',
'uid': 'user-1',
'content': 'Short-term fact',
'category': 'system',
'layer': 'short_term',
'created_at': '2026-06-21T10:00:00.000Z',
'updated_at': '2026-06-21T10:05:00.000Z',
'visibility': 'private',
});
expect(memory.layer, MemoryLayer.shortTerm);
expect(memory.layerIsExplicit, isTrue);
});
test('memory_tier alias decodes to layer', () {
final memory = Memory.fromJson({
'id': 'mem-archive-1',
'uid': 'user-1',
'content': 'Archived fact',
'category': 'manual',
'memory_tier': 'archive',
'created_at': '2026-06-21T10:00:00.000Z',
'updated_at': '2026-06-21T10:05:00.000Z',
'visibility': 'private',
});
expect(memory.layer, MemoryLayer.archive);
expect(memory.layerIsExplicit, isTrue);
});
test('missing layer defaults to long term without explicit flag', () {
final memory = Memory.fromJson({
'id': 'legacy-1',
'uid': 'user-1',
'content': 'Legacy memory',
'category': 'interesting',
'created_at': '2026-06-21T10:00:00.000Z',
'updated_at': '2026-06-21T10:05:00.000Z',
'visibility': 'private',
});
expect(memory.layer, MemoryLayer.longTerm);
expect(memory.layerIsExplicit, isFalse);
});
test('layer preferred over tier alias when both present', () {
final memory = Memory.fromJson({
'id': 'mem-priority',
'uid': 'user-1',
'content': 'Priority test',
'category': 'system',
'layer': 'short_term',
'tier': 'long_term',
'created_at': '2026-06-21T10:00:00.000Z',
'updated_at': '2026-06-21T10:05:00.000Z',
'visibility': 'private',
});
expect(memory.layer, MemoryLayer.shortTerm);
expect(memory.layerIsExplicit, isTrue);
});
});
}