@@ -35,6 +35,15 @@ void main() {
35
35
expect (posts.first, {'title' : 'Hello, world!' });
36
36
});
37
37
38
+ test ('Insert then select' , () async {
39
+ // Test inserting a record
40
+ final posts = await mockSupabase
41
+ .from ('posts' )
42
+ .insert ({'title' : 'Hello, world!' }).select ();
43
+ expect (posts.length, 1 );
44
+ expect (posts.first, {'title' : 'Hello, world!' });
45
+ });
46
+
38
47
test ('Upsert' , () async {
39
48
// Test upserting a record
40
49
await mockSupabase
@@ -50,6 +59,20 @@ void main() {
50
59
expect (postsUfterUpdate.first, {'id' : 1 , 'title' : 'Updated post' });
51
60
});
52
61
62
+ test ('Upsert then select' , () async {
63
+ // Test upserting a record
64
+ await mockSupabase
65
+ .from ('posts' )
66
+ .upsert ({'id' : 1 , 'title' : 'Initial post' });
67
+ final posts = await mockSupabase.from ('posts' ).select ();
68
+ expect (posts.first, {'id' : 1 , 'title' : 'Initial post' });
69
+ final postsAfterUpdate = await mockSupabase
70
+ .from ('posts' )
71
+ .upsert ({'id' : 1 , 'title' : 'Updated post' }).select ();
72
+ expect (postsAfterUpdate.length, 1 );
73
+ expect (postsAfterUpdate.first, {'id' : 1 , 'title' : 'Updated post' });
74
+ });
75
+
53
76
test ('Update' , () async {
54
77
// Test updating a record
55
78
await mockSupabase
@@ -63,6 +86,20 @@ void main() {
63
86
expect (posts.first, {'id' : 1 , 'title' : 'Updated title' });
64
87
});
65
88
89
+ test ('Update then select' , () async {
90
+ // Test updating a record
91
+ await mockSupabase
92
+ .from ('posts' )
93
+ .insert ({'id' : 1 , 'title' : 'Original title' });
94
+ final posts = await mockSupabase
95
+ .from ('posts' )
96
+ .update ({'title' : 'Updated title' })
97
+ .eq ('id' , 1 )
98
+ .select ();
99
+ expect (posts.length, 1 );
100
+ expect (posts.first, {'id' : 1 , 'title' : 'Updated title' });
101
+ });
102
+
66
103
test ('Delete' , () async {
67
104
// Test deleting a record
68
105
await mockSupabase
@@ -72,6 +109,19 @@ void main() {
72
109
final posts = await mockSupabase.from ('posts' ).select ();
73
110
expect (posts.length, 0 );
74
111
});
112
+
113
+ test ('Delete then select' , () async {
114
+ // Test deleting a record
115
+ await mockSupabase
116
+ .from ('posts' )
117
+ .insert ({'id' : 1 , 'title' : 'To be deleted' });
118
+ final deleted =
119
+ await mockSupabase.from ('posts' ).delete ().eq ('id' , 1 ).select ();
120
+ expect (deleted.length, 1 );
121
+ final posts = await mockSupabase.from ('posts' ).select ();
122
+ expect (posts.length, 0 );
123
+ });
124
+
75
125
test ('Select all columns' , () async {
76
126
// Test selecting all records
77
127
await mockSupabase.from ('posts' ).insert ([
0 commit comments