mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 22:15:51 +01:00
Migrating testcase to ScalaTest
This commit is contained in:
@@ -1,26 +1,25 @@
|
||||
package gitbucket.core.model
|
||||
|
||||
import gitbucket.core.model.CommitState._
|
||||
|
||||
import org.specs2.mutable.Specification
|
||||
import org.scalatest.FunSpec
|
||||
|
||||
|
||||
class CommitStateSpec extends Specification {
|
||||
"CommitState" should {
|
||||
"combine empty must eq PENDING" in {
|
||||
combine(Set()) must_== PENDING
|
||||
class CommitStateSpec extends FunSpec {
|
||||
describe("CommitState") {
|
||||
it("should combine empty must eq PENDING") {
|
||||
assert(combine(Set()) == PENDING)
|
||||
}
|
||||
"combine includes ERROR must eq FAILURE" in {
|
||||
combine(Set(ERROR, SUCCESS, PENDING)) must_== FAILURE
|
||||
it("should combine includes ERROR must eq FAILURE") {
|
||||
assert(combine(Set(ERROR, SUCCESS, PENDING)) == FAILURE)
|
||||
}
|
||||
"combine includes FAILURE must eq peinding" in {
|
||||
combine(Set(FAILURE, SUCCESS, PENDING)) must_== FAILURE
|
||||
it("should combine includes FAILURE must eq peinding") {
|
||||
assert(combine(Set(FAILURE, SUCCESS, PENDING)) == FAILURE)
|
||||
}
|
||||
"combine includes PENDING must eq peinding" in {
|
||||
combine(Set(PENDING, SUCCESS)) must_== PENDING
|
||||
it("should combine includes PENDING must eq peinding") {
|
||||
assert(combine(Set(PENDING, SUCCESS)) == PENDING)
|
||||
}
|
||||
"combine only SUCCESS must eq SUCCESS" in {
|
||||
combine(Set(SUCCESS)) must_== SUCCESS
|
||||
it("should combine only SUCCESS must eq SUCCESS") {
|
||||
assert(combine(Set(SUCCESS)) == SUCCESS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,35 @@
|
||||
package gitbucket.core.ssh
|
||||
|
||||
import org.specs2.mutable._
|
||||
import org.specs2.mock.Mockito
|
||||
import org.apache.sshd.server.command.UnknownCommand
|
||||
import javax.servlet.ServletContext
|
||||
import org.scalatest.FunSpec
|
||||
|
||||
class GitCommandFactorySpec extends Specification with Mockito {
|
||||
class GitCommandFactorySpec extends FunSpec {
|
||||
|
||||
val factory = new GitCommandFactory("http://localhost:8080")
|
||||
|
||||
"createCommand" should {
|
||||
"returns GitReceivePack when command is git-receive-pack" in {
|
||||
factory.createCommand("git-receive-pack '/owner/repo.git'").isInstanceOf[DefaultGitReceivePack] must beTrue
|
||||
factory.createCommand("git-receive-pack '/owner/repo.wiki.git'").isInstanceOf[DefaultGitReceivePack] must beTrue
|
||||
|
||||
describe("createCommand") {
|
||||
it("should return GitReceivePack when command is git-receive-pack"){
|
||||
assert(factory.createCommand("git-receive-pack '/owner/repo.git'").isInstanceOf[DefaultGitReceivePack] == true)
|
||||
assert(factory.createCommand("git-receive-pack '/owner/repo.wiki.git'").isInstanceOf[DefaultGitReceivePack] == true)
|
||||
}
|
||||
"returns GitUploadPack when command is git-upload-pack" in {
|
||||
factory.createCommand("git-upload-pack '/owner/repo.git'").isInstanceOf[DefaultGitUploadPack] must beTrue
|
||||
factory.createCommand("git-upload-pack '/owner/repo.wiki.git'").isInstanceOf[DefaultGitUploadPack] must beTrue
|
||||
|
||||
it("should return GitUploadPack when command is git-upload-pack"){
|
||||
assert(factory.createCommand("git-upload-pack '/owner/repo.git'").isInstanceOf[DefaultGitUploadPack] == true)
|
||||
assert(factory.createCommand("git-upload-pack '/owner/repo.wiki.git'").isInstanceOf[DefaultGitUploadPack] == true)
|
||||
}
|
||||
"returns UnknownCommand when command is not git-(upload|receive)-pack" in {
|
||||
factory.createCommand("git- '/owner/repo.git'").isInstanceOf[UnknownCommand] must beTrue
|
||||
factory.createCommand("git-pack '/owner/repo.git'").isInstanceOf[UnknownCommand] must beTrue
|
||||
factory.createCommand("git-a-pack '/owner/repo.git'").isInstanceOf[UnknownCommand] must beTrue
|
||||
factory.createCommand("git-up-pack '/owner/repo.git'").isInstanceOf[UnknownCommand] must beTrue
|
||||
factory.createCommand("\ngit-upload-pack '/owner/repo.git'").isInstanceOf[UnknownCommand] must beTrue
|
||||
it("should return UnknownCommand when command is not git-(upload|receive)-pack"){
|
||||
assert(factory.createCommand("git- '/owner/repo.git'").isInstanceOf[UnknownCommand] == true)
|
||||
assert(factory.createCommand("git-pack '/owner/repo.git'").isInstanceOf[UnknownCommand] == true)
|
||||
assert(factory.createCommand("git-a-pack '/owner/repo.git'").isInstanceOf[UnknownCommand] == true)
|
||||
assert(factory.createCommand("git-up-pack '/owner/repo.git'").isInstanceOf[UnknownCommand] == true)
|
||||
assert(factory.createCommand("\ngit-upload-pack '/owner/repo.git'").isInstanceOf[UnknownCommand] == true)
|
||||
}
|
||||
"returns UnknownCommand when git command has no valid arguments" in {
|
||||
it("should return UnknownCommand when git command has no valid arguments"){
|
||||
// must be: git-upload-pack '/owner/repository_name.git'
|
||||
factory.createCommand("git-upload-pack").isInstanceOf[UnknownCommand] must beTrue
|
||||
factory.createCommand("git-upload-pack /owner/repo.git").isInstanceOf[UnknownCommand] must beTrue
|
||||
factory.createCommand("git-upload-pack 'owner/repo.git'").isInstanceOf[UnknownCommand] must beTrue
|
||||
factory.createCommand("git-upload-pack '/ownerrepo.git'").isInstanceOf[UnknownCommand] must beTrue
|
||||
factory.createCommand("git-upload-pack '/owner/repo.wiki'").isInstanceOf[UnknownCommand] must beTrue
|
||||
assert(factory.createCommand("git-upload-pack").isInstanceOf[UnknownCommand] == true)
|
||||
assert(factory.createCommand("git-upload-pack /owner/repo.git").isInstanceOf[UnknownCommand] == true)
|
||||
assert(factory.createCommand("git-upload-pack 'owner/repo.git'").isInstanceOf[UnknownCommand] == true)
|
||||
assert(factory.createCommand("git-upload-pack '/ownerrepo.git'").isInstanceOf[UnknownCommand] == true)
|
||||
assert(factory.createCommand("git-upload-pack '/owner/repo.wiki'").isInstanceOf[UnknownCommand] == true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user