|
19 | 19 | import static com.google.common.truth.Truth.assertThat;
|
20 | 20 | import static junit.framework.TestCase.assertNotNull;
|
21 | 21 |
|
| 22 | +import com.google.cloud.bigquery.Field; |
| 23 | +import com.google.cloud.bigquery.Schema; |
| 24 | +import com.google.cloud.bigquery.StandardSQLTypeName; |
22 | 25 | import java.io.ByteArrayOutputStream;
|
23 | 26 | import java.io.PrintStream;
|
| 27 | +import java.util.UUID; |
24 | 28 | import java.util.concurrent.TimeUnit;
|
25 | 29 | import org.junit.After;
|
26 | 30 | import org.junit.Before;
|
@@ -58,8 +62,13 @@ public void tearDown() {
|
58 | 62 |
|
59 | 63 | @Test
|
60 | 64 | public void updateTableExpiration() {
|
61 |
| - String tableName = "update_expiration_table"; |
62 |
| - CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, null); |
| 65 | + String suffix = UUID.randomUUID().toString().replace('-', '_'); |
| 66 | + String tableName = "update_expiration_table_" + suffix; |
| 67 | + Schema schema = |
| 68 | + Schema.of( |
| 69 | + Field.of("stringField", StandardSQLTypeName.STRING), |
| 70 | + Field.of("booleanField", StandardSQLTypeName.BOOL)); |
| 71 | + CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, schema); |
63 | 72 | Long newExpiration = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
|
64 | 73 | UpdateTableExpiration.updateTableExpiration(BIGQUERY_DATASET_NAME, tableName, newExpiration);
|
65 | 74 | assertThat(bout.toString()).contains("Table expiration updated successfully");
|
|
0 commit comments