Skip to content

Commit

Permalink
Rename schema to key_value_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Apr 4, 2024
1 parent 534a505 commit 5d374a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
34 changes: 20 additions & 14 deletions Tests/RealtimeTests/RealtimeIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,29 @@ final class RealtimeIntegrationTests: XCTestCase {
}

let key = try await (
db.from("store")
db.from("key_value_storage")
.insert(["key": AnyJSON.string(UUID().uuidString), "value": "value1"]).select().single()
.execute().value as Entry
).key
try await db.from("store").update(["value": "value2"]).eq("key", value: key).execute()
try await db.from("store").delete().eq("key", value: key).execute()

let insertedEntries = try await receivedInsertActions.value.map { try $0.decodeRecord(
as: Entry.self,
decoder: JSONDecoder()
) }
let updatedEntries = try await receivedUpdateActions.value.map { try $0.decodeRecord(
as: Entry.self,
decoder: JSONDecoder()
) }
let deletedEntryIds = await receivedDeleteActions.value
.compactMap { $0.oldRecord["key"]?.stringValue }
try await db.from("key_value_storage").update(["value": "value2"]).eq("key", value: key)
.execute()
try await db.from("key_value_storage").delete().eq("key", value: key).execute()

let insertedEntries = try await receivedInsertActions.value.map {
try $0.decodeRecord(
as: Entry.self,
decoder: JSONDecoder()
)
}
let updatedEntries = try await receivedUpdateActions.value.map {
try $0.decodeRecord(
as: Entry.self,
decoder: JSONDecoder()
)
}
let deletedEntryIds = await receivedDeleteActions.value.compactMap {
$0.oldRecord["key"]?.stringValue
}

XCTAssertNoDifference(insertedEntries, [Entry(key: key, value: "value1")])
XCTAssertNoDifference(updatedEntries, [Entry(key: key, value: "value2")])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
create table store(
create table key_value_storage(
"key" text primary key,
"value" jsonb not null
);

alter publication supabase_realtime
add table store;
add table key_value_storage;

0 comments on commit 5d374a1

Please sign in to comment.