Skip to content

Commit

Permalink
Fix/update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaen committed May 5, 2021
1 parent 433e92c commit d7a02c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/cli/stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ func TestStopFallsBackToYesterday(t *testing.T) {
`, state.writtenFileContents)
}

func TestStopWithSummary(t *testing.T) {
func TestStopWithExtendingSummary(t *testing.T) {
state, err := NewTestingContext()._SetRecords(`
1920-02-02
11:22-? Started something...
`)._SetNow(1920, 2, 2, 15, 24)._Run((&Stop{
AtDateArgs: lib.AtDateArgs{Date: klog.Ɀ_Date_(1920, 2, 2)},
Summary: " Done!",
Summary: "Done!",
}).Run)
require.Nil(t, err)
assert.Equal(t, `
Expand Down
24 changes: 22 additions & 2 deletions src/parser/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,27 @@ func TestReconcilerRejectsInvalidEntry(t *testing.T) {
assert.Error(t, err)
}

func TestReconcilerClosesOpenRange(t *testing.T) {
func TestReconcilerClosesOpenRangeWithNewSummary(t *testing.T) {
original := `
2018-01-01
15:00 - ?
`
pr, _ := Parse(original)
reconciler := NewRecordReconciler(pr, func(r Record) bool {
return r.Date().ToString() == "2018-01-01"
})
require.NotNil(t, reconciler)
result, err := reconciler.CloseOpenRange(func(r Record) (Time, Summary) {
return Ɀ_Time_(15, 22), "Finished."
})
require.Nil(t, err)
assert.Equal(t, `
2018-01-01
15:00 - 15:22 Finished.
`, result.NewText)
}

func TestReconcilerClosesOpenRangeWithExtendingSummary(t *testing.T) {
original := `
2018-01-01
1h
Expand All @@ -93,7 +113,7 @@ func TestReconcilerClosesOpenRange(t *testing.T) {
})
require.NotNil(t, reconciler)
result, err := reconciler.CloseOpenRange(func(r Record) (Time, Summary) {
return Ɀ_Time_(16, 42), " Yes!"
return Ɀ_Time_(16, 42), "Yes!"
})
require.Nil(t, err)
assert.Equal(t, `
Expand Down

0 comments on commit d7a02c9

Please sign in to comment.