Skip to content

Commit 0d4d42e

Browse files
committed
Added test coverage for defaultLinuxInstallLocation and defaultLinuxLogsLocation for init.d files generated upon creation of rpm
1 parent 1550e6d commit 0d4d42e

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
enablePlugins(JavaServerAppPackaging)
2+
3+
name := "rpm-test"
4+
5+
version := "0.1.0"
6+
7+
maintainer := "Josh Suereth <[email protected]>"
8+
9+
packageSummary := "Test rpm package"
10+
11+
executableScriptName := "rpm-exec"
12+
13+
packageDescription := """A fun package description of our software,
14+
with multiple lines."""
15+
16+
rpmRelease := "1"
17+
18+
rpmVendor := "typesafe"
19+
20+
rpmUrl := Some("http://github.com/sbt/sbt-native-packager")
21+
22+
rpmLicense := Some("BSD")
23+
24+
defaultLinuxInstallLocation := "/opt/test"
25+
26+
defaultLinuxLogsLocation := "/opt/test/log"
27+
28+
TaskKey[Unit]("unzip") <<= (baseDirectory, packageBin in Rpm, streams) map { (baseDir, rpmFile, streams) =>
29+
val rpmPath = Seq(rpmFile.getAbsolutePath)
30+
Process("rpm2cpio" , rpmPath) #| Process("cpio -i --make-directories") ! streams.log
31+
()
32+
}
33+
34+
TaskKey[Unit]("check-init-file") <<= (baseDirectory, streams) map { (target, out) =>
35+
val initd = IO.read(target / "etc" / "init.d" / "rpm-test")
36+
assert(initd contains "/opt/test/rpm-test", "defaultLinuxInstallLocation not overriden in init.d\n" + initd)
37+
assert(initd contains "/opt/test/log/rpm-test/rpm-test.log", "defaultLinuxLogsLocation not overriden in init.d\n" + initd)
38+
out.log.success("Successfully tested rpm-test file")
39+
()
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package test
2+
3+
object Main {
4+
def main (args: Array[String]) {
5+
//server app imitation
6+
while (true){
7+
Thread.sleep(1000L)
8+
}
9+
}
10+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Run the rpm packaging.
2+
> rpm:package-bin
3+
$ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm
4+
5+
> unzip
6+
$ exists opt/test/rpm-test
7+
8+
$ exists etc/init.d/rpm-test
9+
> check-init-file
10+

0 commit comments

Comments
 (0)