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

Function TestCtxWorkflow

base/logging_context_test.go:232–258  ·  view source on GitHub ↗

Tests the typical request workflow for a database request. Makes sure each level of context does not modify earlier levels.

(t *testing.T)

Source from the content-addressed store, hash-verified

230
231// Tests the typical request workflow for a database request. Makes sure each level of context does not modify earlier levels.
232func TestCtxWorkflow(t *testing.T) {
233 ctx := TestCtx(t)
234 RequireLogMessage(t, ctx, "[INF] t:TestCtxWorkflow foobar\n", standardMessage)
235
236 correlationCtx := CorrelationIDLogCtx(ctx, "correlationID")
237 RequireLogMessage(t, correlationCtx, "[INF] t:TestCtxWorkflow c:correlationID foobar\n", standardMessage)
238 RequireLogMessage(t, ctx, "[INF] t:TestCtxWorkflow foobar\n", standardMessage)
239
240 bucketCtx := BucketNameCtx(correlationCtx, "fooBucket")
241 RequireLogMessage(t, bucketCtx, "[INF] t:TestCtxWorkflow c:correlationID b:fooBucket foobar\n", standardMessage)
242 RequireLogMessage(t, correlationCtx, "[INF] t:TestCtxWorkflow c:correlationID foobar\n", standardMessage)
243 RequireLogMessage(t, ctx, "[INF] t:TestCtxWorkflow foobar\n", standardMessage)
244
245 keyspaceCtx := KeyspaceLogCtx(bucketCtx, "fooBucket", "fooScope", "fooCollection")
246 RequireLogMessage(t, keyspaceCtx, "[INF] t:TestCtxWorkflow c:correlationID b:fooBucket.fooScope.fooCollection foobar\n", standardMessage)
247 RequireLogMessage(t, bucketCtx, "[INF] t:TestCtxWorkflow c:correlationID b:fooBucket foobar\n", standardMessage)
248 RequireLogMessage(t, correlationCtx, "[INF] t:TestCtxWorkflow c:correlationID foobar\n", standardMessage)
249 RequireLogMessage(t, ctx, "[INF] t:TestCtxWorkflow foobar\n", standardMessage)
250
251 databaseCtx := DatabaseLogCtx(keyspaceCtx, "fooDB", nil)
252 RequireLogMessage(t, databaseCtx, "[INF] t:TestCtxWorkflow c:correlationID db:fooDB col:fooCollection foobar\n", standardMessage)
253 RequireLogMessage(t, keyspaceCtx, "[INF] t:TestCtxWorkflow c:correlationID b:fooBucket.fooScope.fooCollection foobar\n", standardMessage)
254 RequireLogMessage(t, bucketCtx, "[INF] t:TestCtxWorkflow c:correlationID b:fooBucket foobar\n", standardMessage)
255 RequireLogMessage(t, correlationCtx, "[INF] t:TestCtxWorkflow c:correlationID foobar\n", standardMessage)
256 RequireLogMessage(t, ctx, "[INF] t:TestCtxWorkflow foobar\n", standardMessage)
257
258}

Callers

nothing calls this directly

Calls 6

TestCtxFunction · 0.85
RequireLogMessageFunction · 0.85
CorrelationIDLogCtxFunction · 0.85
BucketNameCtxFunction · 0.85
KeyspaceLogCtxFunction · 0.85
DatabaseLogCtxFunction · 0.85

Tested by

no test coverage detected