Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Name collisions on tests #1466

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import java.util.UUID;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -35,7 +36,6 @@ public class DatasetApiIT {
private static final String PROJECT_ID = "java-docs-samples-testing";
private static final String BUCKET = PROJECT_ID + "-vcm";
private static final String COMPUTE_REGION = "us-central1";
private static final String DATASET_NAME = "test_vision_dataset";
private ByteArrayOutputStream bout;
private PrintStream out;
private String datasetId;
Expand All @@ -54,8 +54,13 @@ public void tearDown() {

@Test
public void testCreateImportDeleteDataset() {
// Create a random dataset name with a length of 32 characters (max allowed by AutoML)
// To prevent name collisions when running tests in multiple java versions at once.
// AutoML doesn't allow "-", but accepts "_"
String datasetName = String.format("test_%s",
UUID.randomUUID().toString().replace("-", "_").substring(0, 26));
// Act
DatasetApi.createDataset(PROJECT_ID, COMPUTE_REGION, DATASET_NAME, false);
DatasetApi.createDataset(PROJECT_ID, COMPUTE_REGION, datasetName, false);

// Assert
String got = bout.toString();
Expand Down