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

Function TestUserN1QLQueries

db/functions/n1ql_function_test.go:96–118  ·  view source on GitHub ↗

Unit test for user N1QL queries.

(t *testing.T)

Source from the content-addressed store, hash-verified

94
95// Unit test for user N1QL queries.
96func TestUserN1QLQueries(t *testing.T) {
97 if base.UnitTestUrlIsWalrus() {
98 t.Skip("This test is Couchbase Server only (requires N1QL)")
99 }
100
101 if base.TestsUseNamedCollections() {
102 t.Skip("Requires collection-aware function security (CBG-2597)")
103 }
104
105 // base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll)
106 db, ctx := setupTestDBWithFunctions(t, &kUserN1QLFunctionsConfig)
107 defer db.Close(ctx)
108
109 // First run the tests as an admin:
110 t.Run("AsAdmin", func(t *testing.T) { testUserQueriesAsAdmin(t, ctx, db) })
111
112 // Now create a user and make it current:
113 db.SetUser(addUserAlice(t, db))
114 assert.True(t, db.User().RoleNames().Contains("hero"))
115
116 // Repeat the tests as user "alice":
117 t.Run("AsUser", func(t *testing.T) { testUserQueriesAsUser(t, ctx, db) })
118}
119
120func testUserQueriesCommon(t *testing.T, ctx context.Context, db *db.Database) {
121 // dynamic channel list

Callers

nothing calls this directly

Calls 12

UnitTestUrlIsWalrusFunction · 0.92
TestsUseNamedCollectionsFunction · 0.92
setupTestDBWithFunctionsFunction · 0.85
addUserAliceFunction · 0.85
SetUserMethod · 0.80
testUserQueriesAsAdminFunction · 0.70
testUserQueriesAsUserFunction · 0.70
CloseMethod · 0.65
RunMethod · 0.65
ContainsMethod · 0.65
RoleNamesMethod · 0.65
UserMethod · 0.45

Tested by

no test coverage detected