Tests the typical request workflow for a database request. Makes sure each level of context does not modify earlier levels.
(t *testing.T)
| 230 | |
| 231 | // Tests the typical request workflow for a database request. Makes sure each level of context does not modify earlier levels. |
| 232 | func 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 | } |
nothing calls this directly
no test coverage detected