Skip to content

Commit

Permalink
Get expected CLI version from resource file
Browse files Browse the repository at this point in the history
  • Loading branch information
losipiuk committed Nov 20, 2020
1 parent 2ee1a03 commit 9f5545e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
17 changes: 17 additions & 0 deletions presto-product-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>presto-cli-version.txt</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>presto-cli-version.txt</exclude>
</excludes>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.io.Files;
import com.google.common.io.Resources;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.airlift.testing.TempFile;
Expand All @@ -27,9 +28,10 @@

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.List;

import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkState;
import static io.prestosql.tempto.fulfillment.table.hive.tpch.TpchTableDefinitions.NATION;
import static io.prestosql.tempto.process.CliProcess.trimLines;
import static io.prestosql.tests.TestGroups.AUTHORIZATION;
Expand Down Expand Up @@ -105,8 +107,19 @@ public void shouldDisplayVersion()
throws IOException
{
launchPrestoCli("--version");
String version = firstNonNull(TestPrestoCli.class.getPackage().getImplementationVersion(), "(version unknown)");
assertThat(presto.readRemainingOutputLines()).containsExactly("Presto CLI " + version);
assertThat(presto.readRemainingOutputLines()).containsExactly("Presto CLI " + readPrestoCliVersion());
}

private static String readPrestoCliVersion()
{
try {
String version = Resources.toString(Resources.getResource("presto-cli-version.txt"), UTF_8).trim();
checkState(!version.isEmpty(), "version is empty");
return version;
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}

@Test(groups = CLI, timeOut = TIMEOUT)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${git.commit.id.describe}

0 comments on commit 9f5545e

Please sign in to comment.