MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestChannelMapperUnderscoreLib

Function TestChannelMapperUnderscoreLib

channels/channelmapper_test.go:240–248  ·  view source on GitHub ↗

channel mapper fn that uses _ underscore JS library

(t *testing.T)

Source from the content-addressed store, hash-verified

238
239// channel mapper fn that uses _ underscore JS library
240func TestChannelMapperUnderscoreLib(t *testing.T) {
241 underscore.Enable() // It really slows down unit tests (by making otto.New take a lot longer)
242 defer underscore.Disable()
243 ctx := base.TestCtx(t)
244 mapper := NewChannelMapper(ctx, `function(doc) {channel(_.first(doc.channels));}`, 0)
245 res, err := mapper.MapToChannelsAndAccess(ctx, parse(t, `{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser)
246 assert.NoError(t, err, "MapToChannelsAndAccess failed")
247 assert.Equal(t, BaseSetOf(t, "foo"), res.Channels)
248}
249
250// Validation by calling reject()
251func TestChannelMapperReject(t *testing.T) {

Callers

nothing calls this directly

Calls 9

TestCtxFunction · 0.92
NewChannelMapperFunction · 0.85
parseFunction · 0.85
emptyMetaMapFunction · 0.85
BaseSetOfFunction · 0.85
EnableMethod · 0.80
DisableMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected