Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions projects/calendar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func TestCalendarCreate(t *testing.T) {
t.Skip("Skipping test because the engine is not initialized")
}

// Only one blocked time calendar is allowed per user, so a leftover from an
// interrupted run makes the "all fields" case fail until it is removed.
deleteBlockedTimeCalendar(t)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I was frequently manually deleting the blocked calendar instance in my test installation when tests failed to do so 😂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah so it wasn't me!!


tests := []struct {
name string
input projects.CalendarCreateRequest
Expand Down Expand Up @@ -55,6 +59,35 @@ func TestCalendarCreate(t *testing.T) {
}
}

// deleteBlockedTimeCalendar removes the user's blocked time calendar if one
// exists, so tests that create one start from a clean slate.
func deleteBlockedTimeCalendar(t *testing.T) {
t.Helper()

ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
t.Cleanup(cancel)

for request := projects.NewCalendarListRequest(); ; {
response, err := projects.CalendarList(ctx, engine, request)
if err != nil {
t.Fatalf("failed to list calendars: %s", err)
}
for _, calendar := range response.Calendars {
if calendar.Type != projects.CalendarTypeBlockedTime {
continue
}
if _, err := projects.CalendarDelete(ctx, engine, projects.NewCalendarDeleteRequest(calendar.ID)); err != nil {
t.Fatalf("failed to delete leftover blocked time calendar: %s", err)
}
}
next := response.Iterate()
if next == nil {
return
}
request = *next
}
}

func TestCalendarDelete(t *testing.T) {
if engine == nil {
t.Skip("Skipping test because the engine is not initialized")
Expand Down
4 changes: 4 additions & 0 deletions projects/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ type Project struct {
// "deleted".
Status ProjectStatus `json:"status"`

// IsBillable indicates whether time logged to the project is billable by
// default.
IsBillable *bool `json:"isBillable"`

// Type is the type of the project. It can be "normal", "tasklists-template",
// "projects-template", "personal", "holder-project", "tentative" or
// "global-messages".
Expand Down
1 change: 1 addition & 0 deletions projects/sparse_fields_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.