Skip to content

Commit ca28e35

Browse files
committed
fix tests for Windows with quoted path
1 parent 06beeeb commit ca28e35

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/org/labkey/test/AssayAPITest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ private void verifyUpdateRunFileAPI(String assayName, String runFileField, int r
425425
"success: callback," +
426426
"failure: callback," +
427427
"rows: [{ RowId: \""+ runRowId + "\"," +
428-
"\"" + EscapeUtil.toJSONStr(runFileField) + "\": \"" + filePath + "\"," +
428+
"\"" + EscapeUtil.toJSONStr(runFileField) + "\": \"" + EscapeUtil.toJSONStr(filePath) + "\"," +
429429
"}]" +
430430
"})";
431431
executeAndVerifyScript(updateScript, errorMsg);

src/org/labkey/test/tests/SampleTypeTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import org.labkey.test.util.SampleTypeHelper;
6363
import org.labkey.test.util.TestDataGenerator;
6464
import org.labkey.test.util.TestUser;
65+
import org.labkey.test.util.data.TestDataUtils;
6566
import org.labkey.test.util.exp.SampleTypeAPIHelper;
6667
import org.openqa.selenium.NoSuchElementException;
6768
import org.openqa.selenium.WebElement;
@@ -1751,9 +1752,9 @@ public void testFilePathOnBulkImport() throws IOException
17511752
private void importSampleTypeFilePathDataError(String sampleName, String filePath)
17521753
{
17531754
final String fileFieldName = "FileField";
1754-
String header = "Name\t" + fileFieldName + "\n";
1755-
String data = sampleName + "\t" + filePath + "\n";
1756-
setFormElement(Locator.name("text"), header + data);
1755+
String pasteData = TestDataUtils.tsvStringFromRowMapsWithQuote(List.of(Map.of("Name", sampleName, fileFieldName, filePath)),
1756+
List.of("Name", fileFieldName), true);
1757+
setFormElement(Locator.name("text"), pasteData);
17571758
new ImportDataPage(getDriver()).submitExpectingError();
17581759
try
17591760
{

src/org/labkey/test/util/data/TestDataUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ public static String tsvStringFromRowMaps(List<Map<String, Object>> rowMaps, Lis
296296
return stringFromRowMaps(rowMaps, columns, includeHeaders, CSVFormat.TDF);
297297
}
298298

299+
public static String tsvStringFromRowMapsWithQuote(List<Map<String, Object>> rowMaps, List<String> columns,
300+
boolean includeHeaders)
301+
{
302+
return stringFromRowMaps(rowMaps, columns, includeHeaders, CSVFormat.MONGODB_TSV);
303+
}
304+
299305
public static <T> List<Map<String, T>> mapsFromRows(List<List<T>> allRows)
300306
{
301307
List<Map<String, T>> rowMaps = new ArrayList<>();
@@ -439,6 +445,12 @@ public static <T> File writeRowsToTsv(String fileName, List<List<T>> rows) throw
439445
return writeRowsToFile(fileName, rows, CSVFormat.TDF);
440446
}
441447

448+
public static <T> File writeRowsToTsvWithQuote(String fileName, List<List<T>> rows) throws IOException
449+
{
450+
return writeRowsToFile(fileName, rows, CSVFormat.MONGODB_TSV);
451+
}
452+
453+
442454
public static <T> File writeRowsToCsv(String fileName, List<List<T>> rows) throws IOException
443455
{
444456
return writeRowsToFile(fileName, rows, CSVFormat.DEFAULT);

0 commit comments

Comments
 (0)