Skip to content

Commit

Permalink
[+] Custom annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
cthulhu committed Jul 4, 2017
1 parent 94089f6 commit be5cc75
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
11 changes: 11 additions & 0 deletions parser/fixtures/file1.go
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
13 changes: 13 additions & 0 deletions parser/parser_suite_test.go
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")
}
81 changes: 81 additions & 0 deletions parser/parser_test.go
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"))
})
})
})

0 comments on commit be5cc75

Please sign in to comment.