Skip to content

Commit

Permalink
Fix creation of symlinks in tests
Browse files Browse the repository at this point in the history
Closes #166
  • Loading branch information
mtdowling committed Sep 23, 2019
1 parent 3cd5f08 commit a5db986
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.SourceLocation;
Expand All @@ -62,6 +66,18 @@

public class ModelAssemblerTest {

private Path outputDirectory;

@BeforeEach
public void before() throws IOException {
outputDirectory = Files.createTempDirectory(getClass().getName());
}

@AfterEach
public void after() throws IOException {
Files.walk(outputDirectory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
}

@Test
public void addsExplicitSuppressions() {
Suppression suppression = Suppression.builder().addValidatorId("foo").build();
Expand Down Expand Up @@ -238,7 +254,7 @@ public void importsSymlinkFileWithAllShapes() throws Exception {
}

public Path createSymbolicLink(Path target, String linkName) throws IOException {
Path link = Paths.get("./src/test/resources", linkName);
Path link = outputDirectory.resolve(linkName);
if (Files.exists(link)) {
Files.delete(link);
}
Expand Down

0 comments on commit a5db986

Please sign in to comment.