Test changing the function
(t *testing.T)
| 410 | |
| 411 | // Test changing the function |
| 412 | func TestSetFunction(t *testing.T) { |
| 413 | ctx := base.TestCtx(t) |
| 414 | mapper := NewChannelMapper(ctx, `function(doc) {channel(doc.channels);}`, 0) |
| 415 | output, err := mapper.MapToChannelsAndAccess(ctx, parse(t, `{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) |
| 416 | assert.NoError(t, err, "MapToChannelsAndAccess failed") |
| 417 | require.Equal(t, BaseSetOf(t, "foo", "baz", "bar"), output.Channels) |
| 418 | changed, err := mapper.SetFunction(`function(doc) {channel("all");}`) |
| 419 | assert.True(t, changed, "SetFunction failed") |
| 420 | assert.NoError(t, err, "SetFunction failed") |
| 421 | output, err = mapper.MapToChannelsAndAccess(ctx, parse(t, `{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) |
| 422 | assert.NoError(t, err, "MapToChannelsAndAccess failed") |
| 423 | assert.Equal(t, BaseSetOf(t, "all"), output.Channels) |
| 424 | } |
| 425 | |
| 426 | // Test that expiry function sets the expiry property |
| 427 | func TestExpiryFunction(t *testing.T) { |
nothing calls this directly
no test coverage detected