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

Function TestOttoValueToStringArray

channels/channelmapper_test.go:40–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38var noUser = map[string]interface{}{"name": nil, "channels": []string{}}
39
40func TestOttoValueToStringArray(t *testing.T) {
41 ctx := base.TestCtx(t)
42 // Test for https://github.com/robertkrimen/otto/issues/24
43 value, _ := otto.New().ToValue([]string{"foo", "bar", "baz"})
44 strings := ottoValueToStringArray(ctx, value)
45 assert.Equal(t, []string{"foo", "bar", "baz"}, strings)
46
47 // Test for https://issues.couchbase.com/browse/CBG-714
48 value, _ = otto.New().ToValue([]interface{}{"a", []interface{}{"b", "g"}, "c", 4})
49 strings = ottoValueToStringArray(ctx, value)
50 assert.Equal(t, []string{"a", "c"}, strings)
51}
52
53// verify that our version of Otto treats JSON parsed arrays like real arrays
54func TestJavaScriptWorks(t *testing.T) {

Callers

nothing calls this directly

Calls 3

TestCtxFunction · 0.92
ottoValueToStringArrayFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected