From d2df88f217cef638bdca527794969fcaa835bfd7 Mon Sep 17 00:00:00 2001 From: Michael Strùˆder Date: Tue, 2 May 2017 17:00:26 +0200 Subject: add test for func (p Parser) Parse() --- todolist/parser_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/todolist/parser_test.go b/todolist/parser_test.go index 8cd6b53..9dfa454 100644 --- a/todolist/parser_test.go +++ b/todolist/parser_test.go @@ -169,3 +169,24 @@ func TestDueIntelligentlyChoosesCorrectYear(t *testing.T) { assert.Equal("2017-01-10", parser.parseArbitraryDate("jan 10", septemberTime)) assert.Equal("2017-01-10", parser.parseArbitraryDate("jan 10", decemberTime)) } + +func TestParseCommandIdSubject(t *testing.T) { + assert := assert.New(t) + parser := Parser{"es 24 a new subject"} + command, id, subject := parser.Parse() + + assert.Equal("es", command) + assert.Equal(24, id) + assert.Equal("a new subject", subject) +} + +func TestParseInvalidCommandIdSubject(t *testing.T) { + assert := assert.New(t) + input := "es a new project" + parser := Parser{input} + command, id, subject := parser.Parse() + + assert.Equal("", command) + assert.Equal(-1, id) + assert.Equal(input, subject) +} -- cgit v1.3