Skip to content

Commit a0cf20d

Browse files
chore: update chat message test (#31)
Co-authored-by: Tabby <tabathal@google.com>
1 parent 7a45e1f commit a0cf20d

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

tests/integration/test_spanner_chat_message_history.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,10 @@ def client() -> Client:
3737
@pytest.fixture(scope="module")
3838
def setup(client):
3939
for env in ["GOOGLE_DATABASE", "PG_DATABASE"]:
40-
google_schema = f"""CREATE TABLE IF NOT EXISTS {table_name} (
41-
id STRING(36) DEFAULT (GENERATE_UUID()),
42-
created_at TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true),
43-
session_id STRING(MAX) NOT NULL,
44-
message JSON NOT NULL,
45-
) PRIMARY KEY (session_id, created_at ASC, id)"""
46-
47-
pg_schema = f"""CREATE TABLE IF NOT EXISTS {table_name} (
48-
id varchar(36) DEFAULT (spanner.generate_uuid()),
49-
created_at SPANNER.COMMIT_TIMESTAMP NOT NULL,
50-
session_id TEXT NOT NULL,
51-
message JSONB NOT NULL,
52-
PRIMARY KEY (session_id, created_at, id)
53-
);"""
5440
database_id = os.environ.get(env)
55-
ddl = pg_schema if env == "PG_DATABASE" else google_schema
56-
database = client.instance(instance_id).database(database_id)
57-
operation = database.update_ddl([ddl])
58-
operation.result(OPERATION_TIMEOUT_SECONDS)
41+
SpannerChatMessageHistory.create_chat_history_table(
42+
instance_id, database_id, table_name
43+
)
5944
yield
6045
for env in ["GOOGLE_DATABASE", "PG_DATABASE"]:
6146
database_id = os.environ.get(env)

0 commit comments

Comments
 (0)