Permalink
Browse files

Adding some test cases for tracking users.

  • Loading branch information...
1 parent 404c0c8 commit e473fac6365b39e2430ba5024d7d6ba87ad9fe93 @digicyc committed May 6, 2012
Showing with 33 additions and 10 deletions.
  1. +6 −2 src/main/scala/SGir.scala
  2. +9 −8 src/test/scala/ChannelPermTest.scala
  3. +18 −0 src/test/scala/UserTest.scala
@@ -100,14 +100,18 @@ object SGir extends PircBot {
checkIn(channel, joiner, login, hostname)
}
+ /**
+ * checkin user or add them into DB if not already.
+ * We want this to return a model.User.
+ */
def checkIn(channel: String, joiner: String, login: String, hostname: String): User = {
val user = User where (_.hostname eqs hostname) get
- if (user == None) {
+ if (user == None || user.size < 1) {
// If no user can be found then we create em.
val newUser = User.createRecord.alias(joiner)
newUser.name("")
- newUser.channel(channel)
+ //newUser.channel(channel)
newUser.hostname(hostname)
newUser.karma(0)
newUser.is_admin(false)
@@ -1,3 +1,5 @@
+package antitech.sgir.test
+
/**
* Test Channel Permisions.
* channel_perm = {"#chan" -> "ops"} = Has Ops
@@ -10,16 +12,15 @@ import antitech.sgir.model.MongoConfig.initTest
import com.foursquare.rogue.Rogue._
class ChannelPermTest extends Specification {
- // Initalize the test DB
- initTest
-
- // Our Test User
- val newUser = User.createRecord.alias("TestUser")
- newUser.channel_perms("#testchan") = OPS
- newUser.save
-
"A person with ops" should {
"have it set" in {
+ initTest
+
+ // Our Test User
+ val newUser = User.createRecord.alias("TestUser")
+ newUser.channel_perms("#testchan") = OPS
+ newUser.save
+
val user =
User where (_.alias eqs "TestUser") get
user.get.channel_perms("#testchan").get mustEqual OPS
@@ -0,0 +1,18 @@
+package antitech.sgir.test
+
+/**
+ * Test cases for managing our Users.
+ */
+
+import org.specs2.mutable._
+
+import antitech.sgir.model.MongoConfig.initTest
+
+class UserTest extends Specification {
+ "A user" should {
+ "be added if not" in {
+ initTest
+
+ }
+ }
+}

0 comments on commit e473fac

Please sign in to comment.