Skip to content

Commit

Permalink
Add spanner system tests:
Browse files Browse the repository at this point in the history
- Write / read back null string.
- Write / read back empty array of string.
- Write / read back null array of string.
- Write / read back array of string with mixed null / non-null values.

Toward #4364.
  • Loading branch information
tseaver committed Nov 9, 2017
1 parent 988e2c2 commit dcf20cd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spanner/tests/_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
name STRING(1024),
value INT64 )
PRIMARY KEY (name);
CREATE TABLE string_plus_array_of_string (
id INT64,
name STRING(16),
tags ARRAY<STRING(16)> )
PRIMARY KEY (id);
"""

DDL_STATEMENTS = [stmt.strip() for stmt in DDL.split(';') if stmt.strip()]
24 changes: 24 additions & 0 deletions spanner/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,30 @@ def test_batch_insert_then_read(self):
rows = list(snapshot.read(self.TABLE, self.COLUMNS, self.ALL))
self._check_row_data(rows)

def test_batch_insert_then_read_string_array_of_string(self):
TABLE = 'string_plus_array_of_string'
COLUMNS = ['id', 'name', 'tags']
ROWDATA = [
(0, None, None),
(1, 'phred', ['yabba', 'dabba', 'do']),
(2, 'bharney', []),
(3, 'wylma', ['oh', None, 'phred']),
]
retry = RetryInstanceState(_has_all_ddl)
retry(self._db.reload)()

session = self._db.session()
session.create()
self.to_delete.append(session)

with session.batch() as batch:
batch.delete(TABLE, self.ALL)
batch.insert(TABLE, COLUMNS, ROWDATA)

snapshot = session.snapshot(read_timestamp=batch.committed)
rows = list(snapshot.read(TABLE, COLUMNS, self.ALL))
self._check_row_data(rows, expected=ROWDATA)

def test_batch_insert_then_read_all_datatypes(self):
retry = RetryInstanceState(_has_all_ddl)
retry(self._db.reload)()
Expand Down

0 comments on commit dcf20cd

Please sign in to comment.