From e325e36c042aee16f5e47555090824805f72a1b7 Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:55:53 -0700 Subject: [PATCH] Expand available path categories (#733) ## Description Add events and contacts. Still cannot create paths of these types though. ## Type of change Please check the type of change your PR introduces: - [x] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [x] :hamster: Trivial/Minor ## Issue(s) #671 ## Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- src/internal/path/categorytype_string.go | 6 ++++-- src/internal/path/resource_path.go | 14 +++++++++++--- src/internal/path/service_category_test.go | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/internal/path/categorytype_string.go b/src/internal/path/categorytype_string.go index a3ad8aa05..b612e19e4 100644 --- a/src/internal/path/categorytype_string.go +++ b/src/internal/path/categorytype_string.go @@ -10,11 +10,13 @@ func _() { var x [1]struct{} _ = x[UnknownCategory-0] _ = x[EmailCategory-1] + _ = x[ContactsCategory-2] + _ = x[EventsCategory-3] } -const _CategoryType_name = "UnknownCategoryemail" +const _CategoryType_name = "UnknownCategoryemailcontactsevents" -var _CategoryType_index = [...]uint8{0, 15, 20} +var _CategoryType_index = [...]uint8{0, 15, 20, 28, 34} func (i CategoryType) String() string { if i < 0 || i >= CategoryType(len(_CategoryType_index)-1) { diff --git a/src/internal/path/resource_path.go b/src/internal/path/resource_path.go index 211440956..4f768f080 100644 --- a/src/internal/path/resource_path.go +++ b/src/internal/path/resource_path.go @@ -27,14 +27,20 @@ type CategoryType int //go:generate stringer -type=CategoryType -linecomment const ( - UnknownCategory CategoryType = iota - EmailCategory // email + UnknownCategory CategoryType = iota + EmailCategory // email + ContactsCategory // contacts + EventsCategory // events ) func toCategoryType(category string) CategoryType { switch category { case EmailCategory.String(): return EmailCategory + case ContactsCategory.String(): + return ContactsCategory + case EventsCategory.String(): + return EventsCategory default: return UnknownCategory } @@ -43,7 +49,9 @@ func toCategoryType(category string) CategoryType { // serviceCategories is a mapping of all valid service/category pairs. var serviceCategories = map[ServiceType]map[CategoryType]struct{}{ ExchangeService: { - EmailCategory: {}, + EmailCategory: {}, + ContactsCategory: {}, + EventsCategory: {}, }, } diff --git a/src/internal/path/service_category_test.go b/src/internal/path/service_category_test.go index 0ef61c536..bc798cdce 100644 --- a/src/internal/path/service_category_test.go +++ b/src/internal/path/service_category_test.go @@ -81,6 +81,22 @@ func (suite *ServiceCategoryUnitSuite) TestValidateServiceAndCategory() { expectedCategory: EmailCategory, check: assert.NoError, }, + { + name: "ExchangeContacts", + service: ExchangeService.String(), + category: ContactsCategory.String(), + expectedService: ExchangeService, + expectedCategory: ContactsCategory, + check: assert.NoError, + }, + { + name: "ExchangeEvents", + service: ExchangeService.String(), + category: EventsCategory.String(), + expectedService: ExchangeService, + expectedCategory: EventsCategory, + check: assert.NoError, + }, } for _, test := range table { suite.T().Run(test.name, func(t *testing.T) {