Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 2975a22

Browse files
authored
Merge pull request #2 from codeoverflow-org/feature/105-plugin-dependencies
Add a test for plugin library dependencies in the testall plugin
2 parents 5a7108d + 9ea3f75 commit 2975a22

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

testall/build.sbt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// GENERATED FILE USING THE CHAT OVERFLOW PLUGIN FRAMEWORK
22

33
name := "testall"
4-
version := "1.0"
4+
version := "1.0"
5+
6+
libraryDependencies += "org.apache.commons" % "commons-math3" % "3.6.1" // used by 'dependencytest'

testall/src/main/scala/org/codeoverflow/plugins/testall/testallPlugin.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.codeoverflow.plugins.testall
22

33
import org.codeoverflow.chatoverflow.api.plugin.{PluginImpl, PluginManager}
4-
import org.codeoverflow.plugins.testall.tests.{discordtest, filetest, serialtest, tipeeestreamtest, twitchtest}
4+
import org.codeoverflow.plugins.testall.tests._
55

66

77
class testallPlugin(manager: PluginManager) extends PluginImpl(manager) {
@@ -26,7 +26,8 @@ class testallPlugin(manager: PluginManager) extends PluginImpl(manager) {
2626
),
2727
new tipeeestreamtest(this,
2828
require.input.tipeeeStream("tipeeestreamEvents", "TipeeeStream event input", true)
29-
)
29+
),
30+
new dependencytest(this)
3031
//Add more tests here!
3132
)
3233

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.codeoverflow.plugins.testall.tests
2+
3+
import org.apache.commons.math3.analysis.function.Sqrt
4+
import org.codeoverflow.plugins.testall.{test, testallPlugin}
5+
6+
/**
7+
* A quick test to ensure that plugins are able to have dependencies by using apache commons math3 to take the square root of a number.
8+
* This dependency has been added in the build.sbt and should be downloaded using Coursier inside the framework.
9+
*/
10+
class dependencytest(val plugin: testallPlugin) extends test(plugin) {
11+
override def name: String = "Dependency test"
12+
13+
override def setup(): Unit = {
14+
try {
15+
val num = 4
16+
val numSquared = num * num
17+
assert(num == new Sqrt().value(numSquared))
18+
log("Dependencies are working as expected")
19+
} catch {
20+
case _: Throwable => log("Dependencies aren't working successfully")
21+
}
22+
}
23+
24+
override def loop(): Unit = ()
25+
26+
override def shutdown(): Unit = ()
27+
}

0 commit comments

Comments
 (0)