Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
- FIXED: View config not respecting tag_order setting
  • Loading branch information
ttscoff committed Nov 18, 2021
1 parent fea6377 commit 88650d1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
5 changes: 2 additions & 3 deletions bin/doing
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,6 @@ command :yesterday do |c|
c.switch [:totals], default_value: false, negatable: false

c.desc 'Sort tags by (name|time)'
default = 'time'
default = settings['tag_sort'] || 'name'
c.arg_name 'KEY'
c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default
Expand Down Expand Up @@ -1941,7 +1940,7 @@ command :view do |c|

c.desc 'Tag sort direction (asc|desc)'
c.arg_name 'DIRECTION'
c.flag [:tag_order], must_match: REGEX_SORT_ORDER, default_value: 'asc'
c.flag [:tag_order], must_match: REGEX_SORT_ORDER

c.desc 'View entries older than date'
c.arg_name 'DATE_STRING'
Expand Down Expand Up @@ -2085,7 +2084,7 @@ command :view do |c|

Doing::Pager.page wwid.list_section(opts)
elsif title.instance_of?(FalseClass)
exit_now! 'Cancelled'
raise UserCancelled, 'Cancelled' unless res
else
raise InvalidView, "View #{title} not found in config"
end
Expand Down
2 changes: 1 addition & 1 deletion test/doing_archive_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_archive_search
assert_match(/Archived: 2 items/, result, 'Should have archived 2 items')

result = doing('--stdout', 'archive', '--search', '/cont.*?ion/')
assert_match(/Archived: 1 items/, result, 'Regex search should have matched 1 items')
assert_match(/Archived: 1 item/, result, 'Regex search should have matched 1 items')

assert_count_entries(entries - 3, doing('show'), "Current section should have 3 fewer items items")
assert_count_entries(3, doing('show', 'archive'), 'Archive should have 3 items')
Expand Down
6 changes: 3 additions & 3 deletions test/doing_done_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def test_finish_tag
end

def test_finish_unfinished
doing('now', '--back=15m', 'Adding an unfinished entry')
doing('done', 'Adding a finished entry')
doing('now', '--back=15m', 'Unfinished entry')
doing('done', 'Finished entry')
result = doing('--stdout', 'finish', '--unfinished')
assert_match(/Tagged: @done added to 1 item/, result, 'Earlier unfinished task should be marked @done')
assert_match(/Tagged: added tag @done to Un/, result, 'Earlier unfinished task should be marked @done')
end

def test_finish_took
Expand Down
4 changes: 2 additions & 2 deletions test/doing_entry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_later_entry
result = doing('--stdout', 'later', subject)
assert_matches([
[/New section: "Later"/, 'should have added Later section'],
[/Added: added 1 new item/, 'should have added entry to Later section']
[/New entry: added "#{subject}" to Later/, 'should have added entry to Later section']
], result)
assert_count_entries(1, doing('show', 'later'), 'There should be one later entry')
end
Expand Down Expand Up @@ -113,7 +113,7 @@ def test_archive_by_search
result = doing('--stdout', 'archive', '--search', '/consuming.*?bagels/')

assert_match(/New section: "Archive"/, result, 'Archive section should have been added')
assert_match(/Archived: 1 items from #{@config['current_section']} to Archive/, result, '1 item should have been archived')
assert_match(/Archived: 1 item from #{@config['current_section']} to Archive/, result, '1 item should have been archived')
assert_match(/consuming @bagels/i, doing('show', 'Archive'), 'Archive section should contain test entry')

result = doing('--stdout', 'archive', '--search', 'eating')
Expand Down
4 changes: 2 additions & 2 deletions test/doing_resume_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def test_resume_entry
doing('done', subject)
result = doing('--stdout', '--debug', 'again')

assert_match(/Entry added: "#{subject}" to #{@config['current_section']}/, result, 'Entry should be added again')
assert_match(/New entry: added "#{subject}" to #{@config['current_section']}/, result, 'Entry should be added again')
end

def test_resume_tag
3.times { |i| doing('done', '--back', "#{i+5}m", "Entry #{i + 1} with @tag#{i + 1}") }
result = doing('--stdout', '--debug', 'again', '--tag', 'tag2')
assert_match(/Entry added: \"Entry 2 with @tag2\"/, result, 'Entry 2 should be repeated')
assert_match(/New entry: added \"Entry 2 with @tag2\"/, result, 'Entry 2 should be repeated')

result = doing('last').uncolor.strip

Expand Down
22 changes: 17 additions & 5 deletions test/test.doingrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
plugins:
plugin_path: test/plugins
command_path: "/Users/ttscoff/.config/doing/commands"
trizzer:
trizzle: test value from config
say:
Expand All @@ -19,16 +20,17 @@ autotag:
- guntzel
doing_file: "~/what_was_i_doing.md"
current_section: Lately
editor_app:
templates:
default:
date_format: "%Y-%m-%d %H:%M"
template: "%date | %title%note"
wrap_width: 0
order: asc
today:
date_format: "%Y-%m-%d %H:%M"
template: "%date | %title %interval%note"
wrap_width: 0
order: asc
last:
date_format: "%-I:%M%P on %a"
template: "%title (at %date)%odnote"
Expand All @@ -37,6 +39,8 @@ templates:
date_format: "%_I:%M%P"
template: "%shortdate: %title (%section)"
wrap_width: 88
count: 10
order: asc
views:
test:
template: "%date | DOING TEST: %title%note"
Expand Down Expand Up @@ -77,8 +81,6 @@ views:
order: asc
marker_tag: flagged
marker_color: red
:include_notes: true
config_editor_app:
export_templates:
css:
haml:
Expand All @@ -94,6 +96,16 @@ export_templates:
doing:
say:
trizzer:
wiki:
tag_sort: name
never_time: ['@nevertime']
never_finish: ['@neverfinish']
never_time:
- "@nevertime"
never_finish:
- "@neverfinish"
timer_format: text
include_notes: true
editors:
default: vim
doing_file:
config:
paginate: false

0 comments on commit 88650d1

Please sign in to comment.