Skip to content

Commit d7a02c9

Browse files
committed
Fix/update tests
1 parent 433e92c commit d7a02c9

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/app/cli/stop_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ func TestStopFallsBackToYesterday(t *testing.T) {
3434
`, state.writtenFileContents)
3535
}
3636

37-
func TestStopWithSummary(t *testing.T) {
37+
func TestStopWithExtendingSummary(t *testing.T) {
3838
state, err := NewTestingContext()._SetRecords(`
3939
1920-02-02
4040
11:22-? Started something...
4141
`)._SetNow(1920, 2, 2, 15, 24)._Run((&Stop{
4242
AtDateArgs: lib.AtDateArgs{Date: klog.Ɀ_Date_(1920, 2, 2)},
43-
Summary: " Done!",
43+
Summary: "Done!",
4444
}).Run)
4545
require.Nil(t, err)
4646
assert.Equal(t, `

src/parser/reconciler_test.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,27 @@ func TestReconcilerRejectsInvalidEntry(t *testing.T) {
8080
assert.Error(t, err)
8181
}
8282

83-
func TestReconcilerClosesOpenRange(t *testing.T) {
83+
func TestReconcilerClosesOpenRangeWithNewSummary(t *testing.T) {
84+
original := `
85+
2018-01-01
86+
15:00 - ?
87+
`
88+
pr, _ := Parse(original)
89+
reconciler := NewRecordReconciler(pr, func(r Record) bool {
90+
return r.Date().ToString() == "2018-01-01"
91+
})
92+
require.NotNil(t, reconciler)
93+
result, err := reconciler.CloseOpenRange(func(r Record) (Time, Summary) {
94+
return Ɀ_Time_(15, 22), "Finished."
95+
})
96+
require.Nil(t, err)
97+
assert.Equal(t, `
98+
2018-01-01
99+
15:00 - 15:22 Finished.
100+
`, result.NewText)
101+
}
102+
103+
func TestReconcilerClosesOpenRangeWithExtendingSummary(t *testing.T) {
84104
original := `
85105
2018-01-01
86106
1h
@@ -93,7 +113,7 @@ func TestReconcilerClosesOpenRange(t *testing.T) {
93113
})
94114
require.NotNil(t, reconciler)
95115
result, err := reconciler.CloseOpenRange(func(r Record) (Time, Summary) {
96-
return Ɀ_Time_(16, 42), " Yes!"
116+
return Ɀ_Time_(16, 42), "Yes!"
97117
})
98118
require.Nil(t, err)
99119
assert.Equal(t, `

0 commit comments

Comments
 (0)