mirror of
https://github.com/zitadel/zitadel.git
synced 2025-10-18 11:33:52 +00:00
fix: all enums same style (#262)
* fix: all enums same style * fix: rename process to reduce * add some missing enum renaming Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -136,9 +136,9 @@ func (a *ApplicationView) AppendEvent(event *models.Event) (err error) {
|
||||
es_model.ApplicationChanged:
|
||||
err = a.SetData(event)
|
||||
case es_model.ApplicationDeactivated:
|
||||
a.State = int32(model.APPSTATE_INACTIVE)
|
||||
a.State = int32(model.AppStateInactive)
|
||||
case es_model.ApplicationReactivated:
|
||||
a.State = int32(model.APPSTATE_ACTIVE)
|
||||
a.State = int32(model.AppStateActive)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
type ApplicationSearchRequest proj_model.ApplicationSearchRequest
|
||||
type ApplicationSearchQuery proj_model.ApplicationSearchQuery
|
||||
type ApplicationSearchKey proj_model.ApplicationSearchKey
|
||||
type ApplicationSearchKey proj_model.AppSearchKey
|
||||
|
||||
func (req ApplicationSearchRequest) GetLimit() uint64 {
|
||||
return req.Limit
|
||||
@@ -19,7 +19,7 @@ func (req ApplicationSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ApplicationSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.APPLICATIONSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.AppSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ApplicationSearchKey(req.SortingColumn)
|
||||
@@ -50,14 +50,14 @@ func (req ApplicationSearchQuery) GetValue() interface{} {
|
||||
}
|
||||
|
||||
func (key ApplicationSearchKey) ToColumnName() string {
|
||||
switch proj_model.ApplicationSearchKey(key) {
|
||||
case proj_model.APPLICATIONSEARCHKEY_APP_ID:
|
||||
switch proj_model.AppSearchKey(key) {
|
||||
case proj_model.AppSearchKeyAppID:
|
||||
return ApplicationKeyID
|
||||
case proj_model.APPLICATIONSEARCHKEY_NAME:
|
||||
case proj_model.AppSearchKeyName:
|
||||
return ApplicationKeyName
|
||||
case proj_model.APPLICATIONSEARCHKEY_PROJECT_ID:
|
||||
case proj_model.AppSearchKeyProjectID:
|
||||
return ApplicationKeyProjectID
|
||||
case proj_model.APPLICATIONSEARCHKEY_OIDC_CLIENT_ID:
|
||||
case proj_model.AppSearchKeyOIDCClientID:
|
||||
return ApplicationKeyOIDCClientID
|
||||
default:
|
||||
return ""
|
||||
|
@@ -34,47 +34,47 @@ func TestApplicationAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ApplicationAdded, Data: mockAppData(&es_model.Application{Name: "AppName"})},
|
||||
app: &ApplicationView{},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append changed app event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ApplicationChanged, Data: mockAppData(&es_model.Application{Name: "AppNameChanged"})},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppNameChanged", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppNameChanged", State: int32(model.AppStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append deactivate app event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ApplicationDeactivated},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_INACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateInactive)},
|
||||
},
|
||||
{
|
||||
name: "append reactivate app event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ApplicationReactivated},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_INACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateInactive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append added oidc config event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.OIDCConfigAdded, Data: mockOIDCConfigData(&es_model.OIDCConfig{ClientID: "clientID"})},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", IsOIDC: true, OIDCClientID: "clientID", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", IsOIDC: true, OIDCClientID: "clientID", State: int32(model.AppStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append changed oidc config event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.OIDCConfigAdded, Data: mockOIDCConfigData(&es_model.OIDCConfig{ClientID: "clientIDChanged"})},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", OIDCClientID: "clientID", State: int32(model.APPSTATE_ACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", OIDCClientID: "clientID", State: int32(model.AppStateActive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", IsOIDC: true, OIDCClientID: "clientIDChanged", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", IsOIDC: true, OIDCClientID: "clientIDChanged", State: int32(model.AppStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@@ -63,16 +63,16 @@ func (p *ProjectView) AppendEvent(event *models.Event) (err error) {
|
||||
p.Sequence = event.Sequence
|
||||
switch event.Type {
|
||||
case es_model.ProjectAdded:
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
p.CreationDate = event.CreationDate
|
||||
p.setRootData(event)
|
||||
err = p.setData(event)
|
||||
case es_model.ProjectChanged:
|
||||
err = p.setData(event)
|
||||
case es_model.ProjectDeactivated:
|
||||
p.State = int32(model.PROJECTSTATE_INACTIVE)
|
||||
p.State = int32(model.ProjectStateInactive)
|
||||
case es_model.ProjectReactivated:
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@@ -88,16 +88,16 @@ func (p *ProjectGrantView) AppendEvent(event *models.Event) (err error) {
|
||||
p.Sequence = event.Sequence
|
||||
switch event.Type {
|
||||
case es_model.ProjectGrantAdded:
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
p.CreationDate = event.CreationDate
|
||||
p.setRootData(event)
|
||||
err = p.setProjectGrantData(event)
|
||||
case es_model.ProjectGrantChanged, es_model.ProjectGrantCascadeChanged:
|
||||
err = p.setProjectGrantData(event)
|
||||
case es_model.ProjectGrantDeactivated:
|
||||
p.State = int32(model.PROJECTSTATE_INACTIVE)
|
||||
p.State = int32(model.ProjectStateInactive)
|
||||
case es_model.ProjectGrantReactivated:
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ func (req ProjectGrantMemberSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectGrantMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.PROJECTGRANTMEMBERSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.ProjectGrantMemberSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectGrantMemberSearchKey(req.SortingColumn)
|
||||
@@ -51,17 +51,17 @@ func (req ProjectGrantMemberSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectGrantMemberSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectGrantMemberSearchKey(key) {
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_EMAIL:
|
||||
case proj_model.ProjectGrantMemberSearchKeyEmail:
|
||||
return ProjectGrantMemberKeyEmail
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_FIRST_NAME:
|
||||
case proj_model.ProjectGrantMemberSearchKeyFirstName:
|
||||
return ProjectGrantMemberKeyFirstName
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_LAST_NAME:
|
||||
case proj_model.ProjectGrantMemberSearchKeyLastName:
|
||||
return ProjectGrantMemberKeyLastName
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_USER_NAME:
|
||||
case proj_model.ProjectGrantMemberSearchKeyUserName:
|
||||
return ProjectGrantMemberKeyUserName
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_USER_ID:
|
||||
case proj_model.ProjectGrantMemberSearchKeyUserID:
|
||||
return ProjectGrantMemberKeyUserID
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_GRANT_ID:
|
||||
case proj_model.ProjectGrantMemberSearchKeyGrantID:
|
||||
return ProjectGrantMemberKeyGrantID
|
||||
default:
|
||||
return ""
|
||||
|
@@ -19,7 +19,7 @@ func (req ProjectGrantSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectGrantSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.GRANTEDPROJECTSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.GrantedProjectSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectGrantSearchKey(req.SortingColumn)
|
||||
@@ -51,17 +51,17 @@ func (req ProjectGrantSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectGrantSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectGrantViewSearchKey(key) {
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_NAME:
|
||||
case proj_model.GrantedProjectSearchKeyName:
|
||||
return ProjectGrantKeyName
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID:
|
||||
case proj_model.GrantedProjectSearchKeyGrantID:
|
||||
return ProjectGrantKeyGrantID
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_ORGID:
|
||||
case proj_model.GrantedProjectSearchKeyOrgID:
|
||||
return ProjectGrantKeyOrgID
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID:
|
||||
case proj_model.GrantedProjectSearchKeyProjectID:
|
||||
return ProjectGrantKeyProjectID
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER:
|
||||
case proj_model.GrantedProjectSearchKeyResourceOwner:
|
||||
return ProjectGrantKeyResourceOwner
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_ROLE_KEYS:
|
||||
case proj_model.GrantedProjectSearchKeyRoleKeys:
|
||||
return ProjectGrantKeyRoleKeys
|
||||
default:
|
||||
return ""
|
||||
|
@@ -36,31 +36,31 @@ func TestProjectGrantAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantAdded, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID", RoleKeys: pq.StringArray{"Role"}})},
|
||||
project: &ProjectGrantView{},
|
||||
},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
{
|
||||
name: "append change project grant event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantChanged, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID", RoleKeys: pq.StringArray{"RoleChanged"}})},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"RoleChanged"}},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"RoleChanged"}},
|
||||
},
|
||||
{
|
||||
name: "append deactivate project grant event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantDeactivated, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID"})},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_INACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateInactive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
{
|
||||
name: "append reactivate project grant event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantReactivated, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID"})},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_INACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateInactive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@@ -19,7 +19,7 @@ func (req ProjectMemberSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.PROJECTMEMBERSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.ProjectMemberSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectMemberSearchKey(req.SortingColumn)
|
||||
@@ -51,17 +51,17 @@ func (req ProjectMemberSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectMemberSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectMemberSearchKey(key) {
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_EMAIL:
|
||||
case proj_model.ProjectMemberSearchKeyEmail:
|
||||
return ProjectMemberKeyEmail
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_FIRST_NAME:
|
||||
case proj_model.ProjectMemberSearchKeyFirstName:
|
||||
return ProjectMemberKeyFirstName
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_LAST_NAME:
|
||||
case proj_model.ProjectMemberSearchKeyLastName:
|
||||
return ProjectMemberKeyLastName
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_USER_NAME:
|
||||
case proj_model.ProjectMemberSearchKeyUserName:
|
||||
return ProjectMemberKeyUserName
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_USER_ID:
|
||||
case proj_model.ProjectMemberSearchKeyUserID:
|
||||
return ProjectMemberKeyUserID
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_PROJECT_ID:
|
||||
case proj_model.ProjectMemberSearchKeyProjectID:
|
||||
return ProjectMemberKeyProjectID
|
||||
default:
|
||||
return ""
|
||||
|
@@ -19,7 +19,7 @@ func (req ProjectSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.PROJECTSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.ProjectViewSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectSearchKey(req.SortingColumn)
|
||||
@@ -51,11 +51,11 @@ func (req ProjectSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectViewSearchKey(key) {
|
||||
case proj_model.PROJECTSEARCHKEY_NAME:
|
||||
case proj_model.ProjectViewSearchKeyName:
|
||||
return ProjectKeyName
|
||||
case proj_model.PROJECTSEARCHKEY_PROJECTID:
|
||||
case proj_model.ProjectViewSearchKeyProjectID:
|
||||
return ProjectKeyProjectID
|
||||
case proj_model.PROJECTSEARCHKEY_RESOURCE_OWNER:
|
||||
case proj_model.ProjectViewSearchKeyResourceOwner:
|
||||
return ProjectKeyResourceOwner
|
||||
default:
|
||||
return ""
|
||||
|
@@ -19,7 +19,7 @@ func (req ProjectRoleSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectRoleSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.PROJECTROLESEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.ProjectRoleSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectRoleSearchKey(req.SortingColumn)
|
||||
@@ -51,13 +51,13 @@ func (req ProjectRoleSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectRoleSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectRoleSearchKey(key) {
|
||||
case proj_model.PROJECTROLESEARCHKEY_KEY:
|
||||
case proj_model.ProjectRoleSearchKeyKey:
|
||||
return ProjectRoleKeyKey
|
||||
case proj_model.PROJECTROLESEARCHKEY_ORGID:
|
||||
case proj_model.ProjectRoleSearchKeyOrgID:
|
||||
return ProjectRoleKeyOrgID
|
||||
case proj_model.PROJECTROLESEARCHKEY_PROJECTID:
|
||||
case proj_model.ProjectRoleSearchKeyProjectID:
|
||||
return ProjectRoleKeyProjectID
|
||||
case proj_model.PROJECTROLESEARCHKEY_RESOURCEOWNER:
|
||||
case proj_model.ProjectRoleSearchKeyResourceOwner:
|
||||
return ProjectRoleKeyResourceOwner
|
||||
default:
|
||||
return ""
|
||||
|
@@ -23,31 +23,31 @@ func TestProjectAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectAdded, ResourceOwner: "OrgID", Data: mockProjectData(&es_model.Project{Name: "ProjectName"})},
|
||||
project: &ProjectView{},
|
||||
},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append change project event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectChanged, ResourceOwner: "OrgID", Data: mockProjectData(&es_model.Project{Name: "ProjectNameChanged"})},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectNameChanged", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectNameChanged", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append project deactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectDeactivated, ResourceOwner: "OrgID"},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_INACTIVE)},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateInactive)},
|
||||
},
|
||||
{
|
||||
name: "append project reactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectReactivated, ResourceOwner: "OrgID"},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_INACTIVE)},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateInactive)},
|
||||
},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
Reference in New Issue
Block a user