damccorm commented on code in PR #31796:
URL: https://github.com/apache/beam/pull/31796#discussion_r1672589090


##########
runners/prism/java/src/test/java/org/apache/beam/runners/prism/PrismLocatorTest.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.prism;
+
+import static com.google.common.truth.Truth.assertThat;
+import static 
org.apache.beam.runners.prism.PrismRunnerTest.getLocalPrismBuildOrIgnoreTest;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import org.apache.beam.sdk.options.PipelineOptionsFactory;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Tests for {@link PrismLocator}. */
+@RunWith(JUnit4.class)
+public class PrismLocatorTest {
+
+  @Test
+  public void givenVersionOverride_thenResolves() throws IOException {
+    PrismPipelineOptions options = options();
+    options.setPrismVersionOverride("2.57.0");
+    PrismLocator underTest = new PrismLocator(options);
+    String got = underTest.resolve();
+    assertThat(got).contains(".apache_beam/cache/prism/bin/");
+    assertThat(got).contains("2.57.0");
+    Path gotPath = Paths.get(got);
+    assertThat(Files.exists(gotPath)).isTrue();
+    Files.delete(gotPath);
+  }
+
+  @Test
+  public void givenHttpPrismLocationOption_thenResolves() throws IOException {
+    PrismPipelineOptions options = options();
+    options.setPrismLocation(
+        
"https://github.com/apache/beam/releases/download/v2.57.0/apache_beam-v2.57.0-prism-darwin-arm64.zip";);
+    PrismLocator underTest = new PrismLocator(options);
+    String got = underTest.resolve();
+    assertThat(got).contains(".apache_beam/cache/prism/bin/");
+    Path gotPath = Paths.get(got);
+    assertThat(Files.exists(gotPath)).isTrue();
+    Files.delete(gotPath);
+  }
+
+  @Test
+  public void givenFilePrismLocationOption_thenResolves() throws IOException {

Review Comment:
   > So the change you are suggesting is to add test setup to delete any files?
   
   Yes, this is one of the suggestions
   
   > A local temp file is out of scope because the goal of PrismLocator is to 
place the file in a prescribed location to maintain consistency with the Python 
prism runner.
   
   I'm open to different solutions, but the problem statement is this: Just 
using this test, how do we know that the file was downloaded from the local 
filesystem, not from the published prism artifact on GitHub? Right now, we are 
testing that we've put something in `.apache_beam/cache/prism/bin/`, but we're 
not verifying that its actually the correct thing.
   
   I suggested using a temp file instead of using whatever is located in 
`getLocalPrismBuildOrIgnoreTest()` since this would give us a way of verifying 
that the artifact placed in `.apache_beam/cache/prism/bin/` is actually the 
local file. I suspect it is not based on 
https://github.com/apache/beam/pull/31796/files#r1671800597, but a more robust 
test would prove me either right or wrong.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to