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

Function TestJavaScriptWorks

channels/channelmapper_test.go:54–60  ·  view source on GitHub ↗

verify that our version of Otto treats JSON parsed arrays like real arrays

(t *testing.T)

Source from the content-addressed store, hash-verified

52
53// verify that our version of Otto treats JSON parsed arrays like real arrays
54func TestJavaScriptWorks(t *testing.T) {
55 ctx := base.TestCtx(t)
56 mapper := NewChannelMapper(ctx, `function(doc) {channel(doc.x.concat(doc.y));}`, 0)
57 res, err := mapper.MapToChannelsAndAccess(ctx, parse(t, `{"x":["abc"],"y":["xyz"]}`), `{}`, emptyMetaMap(), noUser)
58 assert.NoError(t, err, "MapToChannelsAndAccess failed")
59 assert.Equal(t, BaseSetOf(t, "abc", "xyz"), res.Channels)
60}
61
62// Just verify that the calls to the channel() fn show up in the output channel list.
63func TestSyncFunction(t *testing.T) {

Callers

nothing calls this directly

Calls 7

TestCtxFunction · 0.92
NewChannelMapperFunction · 0.85
parseFunction · 0.85
emptyMetaMapFunction · 0.85
BaseSetOfFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected