Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cleanup ItemIdList test && ensime-sbt-cmd added #110

Merged
merged 4 commits into from

2 participants

@rvoicilas

No description provided.

rvoicilas added some commits
@rvoicilas rvoicilas Add ensime-sbt-cmd as a sbt plugin
This automatically adds 'ensime generate' command to sbt (which will
write an .ensime file to the project's root directory)
7a13809
@rvoicilas rvoicilas Move ItemIdListSpec out of KestrelHandlerSpec
- have ItemIdListSpec in its own file
- make tests more simple and readable
a45e2ce
@zuercher

this should probably be iil.popAll() mustEqual seq -- otherwise the failure message would report the wrong sequence as the expected values.

Didn't know that, I kind of tried to simulate assertEquals(expected, actual), but it seems it's not the case with Scala Specs.

@zuercher

i believe you can leave this off -- a new instance of the spec should be instantiated for each test, iirc; and if that's true then iil should be a val

Agreed, that should be fixed now.

@zuercher

looks like this test got dropped from your version

I dropped these tests on purpose as most of what they were testing was already tested in smaller, more readable tests within the spec. But I agree that combining various scenarios, even though leads to a more complex tests, can be beneficial. I added this tests back in a separate commit.

@zuercher

looks like this test got dropped from your version

@zuercher zuercher merged commit d3dbb89 into twitter:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 31, 2012
  1. @rvoicilas

    Add ensime-sbt-cmd as a sbt plugin

    rvoicilas authored
    This automatically adds 'ensime generate' command to sbt (which will
    write an .ensime file to the project's root directory)
  2. @rvoicilas

    Move ItemIdListSpec out of KestrelHandlerSpec

    rvoicilas authored
    - have ItemIdListSpec in its own file
    - make tests more simple and readable
Commits on Sep 6, 2012
  1. @rvoicilas
  2. @rvoicilas
This page is out of date. Refresh to see the latest.
View
2  project/plugins.sbt
@@ -22,3 +22,5 @@ externalResolvers <<= (resolvers) map identity
addSbtPlugin("com.twitter" %% "sbt-package-dist" % "1.0.5")
addSbtPlugin("com.twitter" %% "sbt11-scrooge" % "1.0.0")
+
+addSbtPlugin("org.ensime" %% "ensime-sbt-cmd" % "0.0.10")
View
75 src/test/scala/net/lag/kestrel/ItemIdListSpec.scala
@@ -0,0 +1,75 @@
+package net.lag.kestrel
+
+import org.specs.Specification
+
+class ItemIdListSpec extends Specification {
+ "ItemIdList" should {
+ val iil = new ItemIdList()
+
+ "add an Integer to the list" in {
+ iil.add(3)
+ iil.size mustEqual 1
+ }
+
+ "add a sequence of Integers to the list" in {
+ iil.add(Seq(1, 2, 3, 4))
+ iil.size mustEqual 4
+ }
+
+ "pop one item at a time" in {
+ iil.add(Seq(90, 99))
+ iil.pop() mustEqual Some(90)
+ iil.pop() mustEqual Some(99)
+ }
+
+ "pop None when there's nothing to pop" in {
+ iil.pop() mustEqual None
+ }
+
+ "pop all items from an index upward" in {
+ iil.add(Seq(1, 2, 3, 4))
+ val expected = Seq(1, 2)
+ val actual = iil.pop(2)
+ expected mustEqual actual
+ }
+
+ "pop all items from the list" in {
+ val seq = Seq(12, 13, 14)
+ iil.add(seq)
+ iil.popAll() mustEqual seq
+ }
+
+ "return empty seq when pop's count is invalid" in {
+ iil.pop(1) mustEqual Seq()
+ }
+
+ "remove a set of items from the list" in {
+ iil.add(Seq(19, 7, 20, 22))
+ val expected = Set(7, 20, 22)
+ iil.remove(expected) mustEqual expected
+ }
+
+ "add and pop" in {
+ iil.add(Seq(5, 4))
+ iil.size mustEqual 2
+ iil.pop() mustEqual Some(5)
+ iil.pop() mustEqual Some(4)
+ iil.pop() mustEqual None
+ }
+
+ "remove from the middle" in {
+ iil.add(Seq(7, 6, 5, 4, 3, 2))
+ iil.pop() mustEqual Some(7)
+ iil.remove(Set(5, 4, 2)) mustEqual Set(5, 4, 2)
+ iil.popAll() mustEqual Seq(6, 3)
+ }
+
+ "remove and pop combined" in {
+ iil.add(Seq(7, 6, 5, 4, 3, 2))
+ iil.remove(Set(6)) mustEqual Set(6)
+ iil.pop() mustEqual Some(7)
+ iil.pop() mustEqual Some(5)
+ iil.popAll() mustEqual Seq(4, 3, 2)
+ }
+ }
+}
View
30 src/test/scala/net/lag/kestrel/KestrelHandlerSpec.scala
@@ -32,36 +32,6 @@ import config._
class FakeKestrelHandler(queues: QueueCollection, maxOpenTransactions: Int)
extends KestrelHandler(queues, maxOpenTransactions, () => "none", 0) with SimplePendingReads
-class ItemIdListSpec extends Specification with TestLogging {
- "ItemIdList" should {
- "add and pop" in {
- val x = new ItemIdList()
- x.add(Seq(5, 4))
- x.size mustEqual 2
- x.pop() mustEqual Some(5)
- x.pop() mustEqual Some(4)
- x.pop() mustEqual None
- }
-
- "remove from the middle" in {
- val x = new ItemIdList()
- x.add(Seq(7, 6, 5, 4, 3, 2))
- x.pop() mustEqual Some(7)
- x.remove(Set(5, 4, 2)) mustEqual Set(5, 4, 2)
- x.popAll() mustEqual Seq(6, 3)
- }
-
- "remove and pop combined" in {
- val x = new ItemIdList()
- x.add(Seq(7, 6, 5, 4, 3, 2))
- x.remove(Set(6)) mustEqual Set(6)
- x.pop() mustEqual Some(7)
- x.pop() mustEqual Some(5)
- x.popAll() mustEqual Seq(4, 3, 2)
- }
- }
-}
-
class KestrelHandlerSpec extends Specification with TempFolder with TestLogging {
val config = new QueueBuilder().apply()
Something went wrong with that request. Please try again.