Implemented category and priority setters in libpit. Started writing unit tests.
This commit is contained in:
parent
c103591941
commit
cfed10c3ed
2
issues/libpit/0012t1.rst
Normal file
2
issues/libpit/0012t1.rst
Normal file
@ -0,0 +1,2 @@
|
||||
Add unit tests for changing an issue's category.
|
||||
================================================
|
2
issues/libpit/0013t1.rst
Normal file
2
issues/libpit/0013t1.rst
Normal file
@ -0,0 +1,2 @@
|
||||
Add unit tests for changing an issue's priority.
|
||||
================================================
|
3
issues/libpit/0014t1.rst
Normal file
3
issues/libpit/0014t1.rst
Normal file
@ -0,0 +1,3 @@
|
||||
Add unit tests covering Issue construction.
|
||||
===========================================
|
||||
|
2
issues/libpit/0015t1.rst
Normal file
2
issues/libpit/0015t1.rst
Normal file
@ -0,0 +1,2 @@
|
||||
Add unit tests covering Project construction.
|
||||
=============================================
|
@ -1,6 +1,6 @@
|
||||
#Sat Feb 13 21:25:03 CST 2010
|
||||
expected.application.version=1.0.0
|
||||
build.number=5
|
||||
#Mon Feb 15 21:53:26 CST 2010
|
||||
expected.application.version=1.1.0
|
||||
build.number=2
|
||||
src.dir=src
|
||||
release.dir=release
|
||||
build.dir=build
|
||||
|
Binary file not shown.
@ -2,17 +2,20 @@ package com.jdbernard.pit
|
||||
|
||||
public class Issue {
|
||||
|
||||
String id
|
||||
final String id
|
||||
Category category
|
||||
int priority
|
||||
String title
|
||||
String text
|
||||
File source
|
||||
|
||||
Issue(File file) {
|
||||
|
||||
def matcher = file.name =~ /(\d{4})([bftc])(\d).*/
|
||||
if (!matcher) return null
|
||||
|
||||
this.source = file
|
||||
|
||||
id = matcher[0][1]
|
||||
category = Category.toCategory(matcher[0][2])
|
||||
priority = matcher[0][3].toInteger()
|
||||
@ -21,4 +24,18 @@ public class Issue {
|
||||
text = file.text
|
||||
}
|
||||
|
||||
void setCategory(Category c) {
|
||||
this.category = c
|
||||
source.renameTo(getFilename())
|
||||
}
|
||||
|
||||
void setPriority(int p) {
|
||||
if (p < 0) priority = 0
|
||||
else if (p > 9) priority = 9
|
||||
else priority = p
|
||||
source.renameTo(getFilename())
|
||||
}
|
||||
|
||||
String getFilename() { return id + category.symbol + priority + ".rst"; }
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,14 @@ class Project {
|
||||
String name
|
||||
Map<String, Issue> issues = [:]
|
||||
Map<String, Project> projects = [:]
|
||||
File source
|
||||
|
||||
Project(File dir, Filter filter = null) {
|
||||
if (!dir.isDirectory())
|
||||
throw new IllegalArgumentException(
|
||||
"${dir.name} is not a directory.")
|
||||
|
||||
this.source = dir
|
||||
this.name = dir.name
|
||||
|
||||
dir.eachFile { child ->
|
||||
@ -31,6 +37,8 @@ class Project {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rename(String newName) { source.renameTo(newName) }
|
||||
|
||||
public void eachIssue(Closure c) {
|
||||
for (i in issues.values()) c.call(i)
|
||||
|
65
libpit/test/com/jdbernard/pit/IssueTest.groovy
Normal file
65
libpit/test/com/jdbernard/pit/IssueTest.groovy
Normal file
@ -0,0 +1,65 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
class IssueTest
|
||||
|
||||
def issues
|
||||
File testDir
|
||||
|
||||
@Before void makeIssueFiles() {
|
||||
File issueFile
|
||||
issues = []
|
||||
|
||||
testDir = new File('testdir')
|
||||
testDir.mkdirs()
|
||||
|
||||
issueFile = new File(testDir, '0001f1.rst')
|
||||
issueFile.write(
|
||||
"Add the killer feature to the killer app.\n" +
|
||||
"=========================================\n\n" +
|
||||
"Make our killer app shine!.")
|
||||
issues << new Issue(issueFile)
|
||||
|
||||
issueFile = new File(testDir, '0002t5.rst')
|
||||
issueFile.write(
|
||||
"Obtain donuts.\n" +
|
||||
"==============\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() {
|
||||
testDir.deleteDir()
|
||||
}
|
||||
|
||||
@Test void testSetCategory() {
|
||||
|
||||
assert issues[0].category == Category.FEATURE
|
||||
assert issues[1].category == Category.TASK
|
||||
|
||||
issues[0].category == Category.CLOSED
|
||||
issues[1].category == Category.TASK
|
||||
|
||||
assert issues[0].category == Category.CLOSED
|
||||
assert issues[1].category == Category.BUG
|
||||
|
||||
assert new File(testDir, '0001c1.rst').exists()
|
||||
assert new File(testDir, '0002b5.rst').exists()
|
||||
assertFalse new File(testDir, '0001f1.rst').exists()
|
||||
assertFalse new File(testDir, '0002t5.rst').exists()
|
||||
}
|
||||
|
||||
@Test void testIssueConstructor() {
|
||||
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" +
|
||||
"=========================================\n\n" +
|
||||
"Make our killer app shine!."
|
||||
assert issue.source == issueFile
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
application.version=1.0.0
|
||||
application.version=1.1.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user