This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from MITLibraries/135_moar_tests
135 Model Tests
- Loading branch information
Showing
23 changed files
with
1,863 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import org.specs2.mutable._ | ||
|
||
import play.api.test._ | ||
import play.api.test.Helpers._ | ||
import models.Channel | ||
import models.Subscriber | ||
import models.User | ||
|
||
class ChannelSpec extends Specification { | ||
|
||
"Channel model" should { | ||
|
||
"#findById" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
Subscriber.all must haveSize(0) | ||
User.create("bob", "bob@example.com", "pwd", "role1") | ||
Subscriber.create(1, "Sub Name", "cat", "contact", Some("link"), Some("logo")) | ||
|
||
Channel.findById(1) must equalTo(None) | ||
Channel.create(Subscriber.findById(1).get.id, "protocol", "mode", "description", "userid", "password", "http://example.com") | ||
Channel.findById(1).get.protocol must equalTo("protocol") | ||
} | ||
} | ||
|
||
"#create" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
Subscriber.all must haveSize(0) | ||
User.create("bob", "bob@example.com", "pwd", "role1") | ||
Subscriber.create(1, "Sub Name", "cat", "contact", Some("link"), Some("logo")) | ||
|
||
Channel.findById(1) must equalTo(None) | ||
Channel.create(Subscriber.findById(1).get.id, "protocol", "mode", "description", "userid", "password", "http://example.com") | ||
Channel.findById(1).get.protocol must equalTo("protocol") | ||
} | ||
} | ||
|
||
"#make" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
Subscriber.all must haveSize(0) | ||
User.create("bob", "bob@example.com", "pwd", "role1") | ||
Subscriber.create(1, "Sub Name", "cat", "contact", Some("link"), Some("logo")) | ||
|
||
Channel.findById(1) must equalTo(None) | ||
val c = Channel.make(Subscriber.findById(1).get.id, "protocol", "mode", "description", "userid", "password", "http://example.com") | ||
c.protocol must equalTo("protocol") | ||
} | ||
} | ||
|
||
"#delete" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
Subscriber.all must haveSize(0) | ||
User.create("bob", "bob@example.com", "pwd", "role1") | ||
Subscriber.create(1, "Sub Name", "cat", "contact", Some("link"), Some("logo")) | ||
|
||
Channel.findById(1) must equalTo(None) | ||
val c = Channel.make(Subscriber.findById(1).get.id, "protocol", "mode", "description", "userid", "password", "http://example.com") | ||
Channel.findById(1) must not equalTo(None) | ||
Channel.delete(c.id) | ||
Channel.findById(1) must equalTo(None) | ||
} | ||
} | ||
|
||
"#recordTransfer" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
Subscriber.all must haveSize(0) | ||
User.create("bob", "bob@example.com", "pwd", "role1") | ||
Subscriber.create(1, "Sub Name", "cat", "contact", Some("link"), Some("logo")) | ||
|
||
Channel.findById(1) must equalTo(None) | ||
var c = Channel.make(Subscriber.findById(1).get.id, "protocol", "mode", "description", "userid", "password", "http://example.com") | ||
c.transfers must equalTo(0) | ||
c.recordTransfer | ||
|
||
//need to reload to get new value | ||
c = Channel.findById(1).get | ||
c.transfers must equalTo(1) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.