Finished libpit 1.1.0. Added change operations (priority, category, etc)
Began unit testing of libpit. Made most of the changes to pit-cli needed to incorporate the new libpit features.
This commit is contained in:
12
libpit/test/com/jdbernard/pit/FilterTest.groovy
Normal file
12
libpit/test/com/jdbernard/pit/FilterTest.groovy
Normal file
@ -0,0 +1,12 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
import org.junit.Test
|
||||
import static org.junit.Assert.assertTrue
|
||||
|
||||
class FilterTest {
|
||||
|
||||
@Test void emptyTest() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
class IssueTest
|
||||
import org.junit.*
|
||||
import static org.junit.Assert.assertTrue
|
||||
import static org.junit.Assert.assertFalse
|
||||
|
||||
class IssueTest {
|
||||
|
||||
def issues
|
||||
File testDir
|
||||
@ -23,43 +27,60 @@ class IssueTest
|
||||
issueFile.write(
|
||||
"Obtain donuts.\n" +
|
||||
"==============\n\n" +
|
||||
"The office is seriously lacking in sugary donuts.\n\n
|
||||
"The office is seriously lacking in sugary donuts.\n\n" +
|
||||
"We must rectify this at once!")
|
||||
issues << new Issue(issueFile)
|
||||
}
|
||||
|
||||
@AfterClass void deleteIssueFiles() {
|
||||
@After void deleteIssueFiles() {
|
||||
testDir.deleteDir()
|
||||
}
|
||||
|
||||
@Test void testSetCategory() {
|
||||
|
||||
assert issues[0].category == Category.FEATURE
|
||||
assert issues[1].category == Category.TASK
|
||||
assertTrue issues[0].category == Category.FEATURE
|
||||
assertTrue issues[1].category == Category.TASK
|
||||
|
||||
issues[0].category == Category.CLOSED
|
||||
issues[1].category == Category.TASK
|
||||
issues[0].category = Category.CLOSED
|
||||
issues[1].category = Category.BUG
|
||||
|
||||
assert issues[0].category == Category.CLOSED
|
||||
assert issues[1].category == Category.BUG
|
||||
assertTrue issues[0].category == Category.CLOSED
|
||||
assertTrue issues[1].category == Category.BUG
|
||||
|
||||
assert new File(testDir, '0001c1.rst').exists()
|
||||
assert new File(testDir, '0002b5.rst').exists()
|
||||
assertTrue new File(testDir, '0001c1.rst').exists()
|
||||
assertTrue new File(testDir, '0002b5.rst').exists()
|
||||
assertFalse new File(testDir, '0001f1.rst').exists()
|
||||
assertFalse new File(testDir, '0002t5.rst').exists()
|
||||
}
|
||||
|
||||
@Test void testIssueConstructor() {
|
||||
@Test void testSetPriority() {
|
||||
|
||||
assertTrue issues[0].priority == 1
|
||||
assertTrue issues[1].priority == 5
|
||||
|
||||
issues[0].priority = 2
|
||||
issues[1].priority = 9
|
||||
|
||||
assertTrue issues[0].priority == 2
|
||||
assertTrue issues[1].priority == 9
|
||||
|
||||
assertTrue new File(testDir, '0001f2.rst').exists()
|
||||
assertTrue new File(testDir, '0002t9.rst').exists()
|
||||
assertFalse new File(testDir, '0001f1.rst').exists()
|
||||
assertFalse new File(testDir, '0002t5.rst').exists()
|
||||
}
|
||||
|
||||
@Test void testConstruction() {
|
||||
File issueFile = new File(testDir, '0001f1.rst')
|
||||
Issue issue = new Issue(issueFile)
|
||||
|
||||
assert issue.id == "0001"
|
||||
assert issue.category == Category.FEATURE
|
||||
assert issue.priority == 1
|
||||
assert issue.title == "Add the killer feature to the killer app."
|
||||
assert issue.text == "Add the killer feature to the killer app.\n" +
|
||||
assertTrue issue.id == "0001"
|
||||
assertTrue issue.category == Category.FEATURE
|
||||
assertTrue issue.priority == 1
|
||||
assertTrue issue.title == "Add the killer feature to the killer app."
|
||||
assertTrue issue.text == "Add the killer feature to the killer app.\n" +
|
||||
"=========================================\n\n" +
|
||||
"Make our killer app shine!."
|
||||
assert issue.source == issueFile
|
||||
assertTrue issue.source == issueFile
|
||||
}
|
||||
}
|
||||
|
115
libpit/test/com/jdbernard/pit/ProjectTest.groovy
Normal file
115
libpit/test/com/jdbernard/pit/ProjectTest.groovy
Normal file
@ -0,0 +1,115 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import static org.junit.Assert.assertTrue
|
||||
import static org.junit.Assert.assertFalse
|
||||
|
||||
class ProjectTest {
|
||||
|
||||
File testDir
|
||||
Project rootProj
|
||||
|
||||
@Before void createTestProjects() {
|
||||
testDir = new File('testdir')
|
||||
testDir.mkdirs()
|
||||
|
||||
def issueFile = new File(testDir, '0001t5.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('Test Issue 1\n' +
|
||||
'============\n\n' +
|
||||
'This is the first test issue.')
|
||||
|
||||
issueFile = new File(testDir, '0002b5.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('Test Bug\n' +
|
||||
'========\n\n' +
|
||||
'Yeah, it is a test bug.')
|
||||
|
||||
issueFile = new File(testDir, '0003f2.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('Important Feature Request\n' +
|
||||
'=========================\n\n' +
|
||||
'Here is our sweet feature. Please implement it!')
|
||||
|
||||
def subDir = new File(testDir, 'subproj1')
|
||||
subDir.mkdirs()
|
||||
|
||||
issueFile = new File(subDir, '0001f3.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('First feature in subproject\n' +
|
||||
'===========================\n\n' +
|
||||
'Please make the grubblers grobble.')
|
||||
|
||||
issueFile = new File(subDir, '0002b4.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('Zippners are not zippning.\n' +
|
||||
'==========================\n\n' +
|
||||
'For some reason, the Zippners are bilperring, not zippning.')
|
||||
|
||||
rootProj = new Project(testDir)
|
||||
}
|
||||
|
||||
@After void deleteTestProjects() {
|
||||
testDir.delete()
|
||||
}
|
||||
|
||||
@Test void testConstruction() {
|
||||
Project proj = new Project(testDir, null)
|
||||
|
||||
assertTrue proj.name == 'testdir'
|
||||
assertTrue proj.issues.size() == 3
|
||||
assertTrue proj.projects.size() == 1
|
||||
|
||||
// Issue construction in general is under test in IssueTest
|
||||
// just check that the issues actually exists
|
||||
assertTrue proj.issues['0001'].id == '0001'
|
||||
assertTrue proj.issues['0001'].title == 'Test Issue 1'
|
||||
|
||||
assertTrue proj.issues['0002'].id == '0002'
|
||||
assertTrue proj.issues['0002'].title == 'Test Bug'
|
||||
|
||||
assertTrue proj.issues['0003'].id == '0003'
|
||||
assertTrue proj.issues['0003'].title == 'Important Feature Request'
|
||||
|
||||
// check sub-project behaviour
|
||||
assertTrue proj.projects.subproj1 != null
|
||||
assertTrue proj.projects.subproj1.name == 'subproj1'
|
||||
assertTrue proj.projects.subproj1.issues.size() == 2
|
||||
assertTrue proj.projects.subproj1.projects.size() == 0
|
||||
assertTrue proj.projects.subproj1.issues['0001'].id == '0001'
|
||||
assertTrue proj.projects.subproj1.issues['0001'].title == 'First feature in subproject'
|
||||
assertTrue proj.projects.subproj1.issues['0002'].id == '0002'
|
||||
assertTrue proj.projects.subproj1.issues['0002'].title == 'Zippners are not zippning.'
|
||||
}
|
||||
|
||||
@Test void testRename() {
|
||||
assert rootProj.name == 'testdir'
|
||||
|
||||
rootProj.rename('renamedTestDir')
|
||||
|
||||
assertTrue rootProj.name == 'renamedTestDir'
|
||||
assertTrue new File('renamedTestDir').exists()
|
||||
}
|
||||
|
||||
/*@Test void testEachIssue() {
|
||||
def expectedList = [rootProj.issues['0001'],
|
||||
rootProj.issues['0002'], rootProj.issues['0003']]
|
||||
|
||||
// sort using default ordering (ids ascending)
|
||||
def actualList = []
|
||||
rootProj.eachIssue { actualList << it }
|
||||
|
||||
assertArrayEquals expectedList, actualList
|
||||
|
||||
// sort using reverse ordering (ids descending)
|
||||
expectedList = expectedList.reverse()
|
||||
actualList = []
|
||||
|
||||
rootProj.eachIssue(
|
||||
new Filter(issueSorter: { -(it.id.toInteger()) }))
|
||||
{ actualList << it }
|
||||
}*/
|
||||
|
||||
}
|
Reference in New Issue
Block a user