-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package file1 | ||
|
||
// TODO: 1 | ||
|
||
// FIXME: 2 | ||
|
||
// OPTIMIZE: 3 | ||
|
||
// BUG: 4 | ||
|
||
// BAD SMELL: 5 |
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,13 @@ | ||
package parser_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"testing" | ||
) | ||
|
||
func TestParser(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Parser Suite") | ||
} |
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,81 @@ | ||
package parser_test | ||
|
||
import ( | ||
. "github.com/cthulhu/go-notes/parser" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Parser", func() { | ||
Context("All annotations", func() { | ||
It("returns information about annotations", func() { | ||
parser := New(false, false, false, "") | ||
Expect(parser.Parse("fixtures/file1.go")).NotTo(HaveOccurred()) | ||
aggregated := parser.Aggregate() | ||
Expect(aggregated).To(ContainSubstring("TODO: 1")) | ||
Expect(aggregated).To(ContainSubstring("FIXME: 2")) | ||
Expect(aggregated).To(ContainSubstring("OPTIMIZE: 3")) | ||
Expect(aggregated).NotTo(ContainSubstring("BUG: 4")) | ||
Expect(aggregated).NotTo(ContainSubstring("BAD SMELL: 5")) | ||
}) | ||
}) | ||
Context("only todos", func() { | ||
It("returns information about annotations", func() { | ||
parser := New(false, true, false, "") | ||
Expect(parser.Parse("fixtures/file1.go")).NotTo(HaveOccurred()) | ||
aggregated := parser.Aggregate() | ||
Expect(aggregated).To(ContainSubstring("TODO: 1")) | ||
Expect(aggregated).NotTo(ContainSubstring("FIXME: 2")) | ||
Expect(aggregated).NotTo(ContainSubstring("OPTIMIZE: 3")) | ||
Expect(aggregated).NotTo(ContainSubstring("BUG: 4")) | ||
Expect(aggregated).NotTo(ContainSubstring("BAD SMELL: 5")) | ||
}) | ||
}) | ||
Context("only fixme's", func() { | ||
It("returns information about annotations", func() { | ||
parser := New(true, false, false, "") | ||
Expect(parser.Parse("fixtures/file1.go")).NotTo(HaveOccurred()) | ||
aggregated := parser.Aggregate() | ||
Expect(aggregated).NotTo(ContainSubstring("TODO: 1")) | ||
Expect(aggregated).To(ContainSubstring("FIXME: 2")) | ||
Expect(aggregated).NotTo(ContainSubstring("OPTIMIZE: 3")) | ||
Expect(aggregated).NotTo(ContainSubstring("BUG: 4")) | ||
Expect(aggregated).NotTo(ContainSubstring("BAD SMELL: 5")) | ||
}) | ||
}) | ||
Context("only optimizes", func() { | ||
It("returns information about annotations", func() { | ||
parser := New(false, false, true, "") | ||
Expect(parser.Parse("fixtures/file1.go")).NotTo(HaveOccurred()) | ||
aggregated := parser.Aggregate() | ||
Expect(aggregated).NotTo(ContainSubstring("TODO: 1")) | ||
Expect(aggregated).NotTo(ContainSubstring("FIXME: 2")) | ||
Expect(aggregated).To(ContainSubstring("OPTIMIZE: 3")) | ||
Expect(aggregated).NotTo(ContainSubstring("BUG: 4")) | ||
Expect(aggregated).NotTo(ContainSubstring("BAD SMELL: 5")) | ||
}) | ||
}) | ||
Context("custom annotation", func() { | ||
It("returns information about BUG", func() { | ||
parser := New(false, false, false, "BUG") | ||
Expect(parser.Parse("fixtures/file1.go")).NotTo(HaveOccurred()) | ||
aggregated := parser.Aggregate() | ||
Expect(aggregated).NotTo(ContainSubstring("TODO: 1")) | ||
Expect(aggregated).NotTo(ContainSubstring("FIXME: 2")) | ||
Expect(aggregated).NotTo(ContainSubstring("OPTIMIZE: 3")) | ||
Expect(aggregated).To(ContainSubstring("BUG: 4")) | ||
Expect(aggregated).NotTo(ContainSubstring("BAD SMELL: 5")) | ||
}) | ||
It("returns information about BAD SMELL", func() { | ||
parser := New(false, false, false, "BUG") | ||
Expect(parser.Parse("fixtures/file1.go")).NotTo(HaveOccurred()) | ||
aggregated := parser.Aggregate() | ||
Expect(aggregated).NotTo(ContainSubstring("TODO: 1")) | ||
Expect(aggregated).NotTo(ContainSubstring("FIXME: 2")) | ||
Expect(aggregated).NotTo(ContainSubstring("OPTIMIZE: 3")) | ||
Expect(aggregated).To(ContainSubstring("BUG: 4")) | ||
Expect(aggregated).NotTo(ContainSubstring("BAD SMELL: 5")) | ||
}) | ||
}) | ||
}) |