Skip to content

Commit 3609e22

Browse files
authored
Feat: Project - add isBillable field (#93)
1 parent 98a35f9 commit 3609e22

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

projects/calendar_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ func TestCalendarCreate(t *testing.T) {
1515
t.Skip("Skipping test because the engine is not initialized")
1616
}
1717

18+
// Only one blocked time calendar is allowed per user, so a leftover from an
19+
// interrupted run makes the "all fields" case fail until it is removed.
20+
deleteBlockedTimeCalendar(t)
21+
1822
tests := []struct {
1923
name string
2024
input projects.CalendarCreateRequest
@@ -55,6 +59,35 @@ func TestCalendarCreate(t *testing.T) {
5559
}
5660
}
5761

62+
// deleteBlockedTimeCalendar removes the user's blocked time calendar if one
63+
// exists, so tests that create one start from a clean slate.
64+
func deleteBlockedTimeCalendar(t *testing.T) {
65+
t.Helper()
66+
67+
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
68+
t.Cleanup(cancel)
69+
70+
for request := projects.NewCalendarListRequest(); ; {
71+
response, err := projects.CalendarList(ctx, engine, request)
72+
if err != nil {
73+
t.Fatalf("failed to list calendars: %s", err)
74+
}
75+
for _, calendar := range response.Calendars {
76+
if calendar.Type != projects.CalendarTypeBlockedTime {
77+
continue
78+
}
79+
if _, err := projects.CalendarDelete(ctx, engine, projects.NewCalendarDeleteRequest(calendar.ID)); err != nil {
80+
t.Fatalf("failed to delete leftover blocked time calendar: %s", err)
81+
}
82+
}
83+
next := response.Iterate()
84+
if next == nil {
85+
return
86+
}
87+
request = *next
88+
}
89+
}
90+
5891
func TestCalendarDelete(t *testing.T) {
5992
if engine == nil {
6093
t.Skip("Skipping test because the engine is not initialized")

projects/project.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ type Project struct {
120120
// "deleted".
121121
Status ProjectStatus `json:"status"`
122122

123+
// IsBillable indicates whether time logged to the project is billable by
124+
// default.
125+
IsBillable *bool `json:"isBillable"`
126+
123127
// Type is the type of the project. It can be "normal", "tasklists-template",
124128
// "projects-template", "personal", "holder-project", "tentative" or
125129
// "global-messages".

projects/sparse_fields_gen.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)