Skip to content

Commit 3a4b9c5

Browse files
committed
Add test
1 parent c6b8af8 commit 3a4b9c5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

channels/channelmapper_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,3 +663,12 @@ func TestGetDefaultSyncFunction(t *testing.T) {
663663
})
664664
}
665665
}
666+
667+
// TestSyncFunctionRecursion ensures that an infinite recursion in the sync function does not cause a stack overflow.
668+
func TestSyncFunctionRecursion(t *testing.T) {
669+
ctx := base.TestCtx(t)
670+
mapper := NewChannelMapper(ctx, `function access(doc) { access("foo", "bar"); }`, 0)
671+
res, err := mapper.MapToChannelsAndAccess(ctx, parse(t, `{"blank": "doc"}`), `{}`, emptyMetaMap(), noUser)
672+
require.ErrorContains(t, err, "Maximum call stack size exceeded")
673+
require.Nil(t, res)
674+
}

0 commit comments

Comments
 (0)