Skip to content

Commit

Permalink
fix channel depth check on parent change
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 committed Jul 29, 2020
1 parent dc9999a commit 9266258
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion service/channel/manager_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ func (m *managerImpl) UpdateChannel(id uuid.UUID, args repository.UpdateChannelA
return ErrTooDeepChannel // ループ検出
}
}
if len(ascs)+1+m.T.getChannelDepth(ch.ID) > m.MaxChannelDepth {
// 親チャンネル + 自分を含めた子チャンネルの深さ
if len(ascs)+m.T.getChannelDepth(ch.ID) > m.MaxChannelDepth {
return ErrTooDeepChannel
}
}
Expand Down
10 changes: 9 additions & 1 deletion service/channel/manager_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,13 @@ func TestManagerImpl_UpdateChannel(t *testing.T) {
Parent: optional.UUIDFrom(pubChannelRootUUID),
},
},
{
ID: cABCE,
Args: repository.UpdateChannelArgs{
UpdaterID: uuid.Must(uuid.NewV4()),
Parent: optional.UUIDFrom(cABCD),
},
},
{
ID: cEFGHI,
Args: repository.UpdateChannelArgs{
Expand All @@ -469,7 +476,8 @@ func TestManagerImpl_UpdateChannel(t *testing.T) {
},
},
}
for i, c := range cases {
for i, cc := range cases {
c := cc
t.Run(strconv.Itoa(i), func(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
Expand Down

0 comments on commit 9266258

Please sign in to comment.