(t *testing.T)
| 63 | } |
| 64 | |
| 65 | func TestLogFormat(t *testing.T) { |
| 66 | testCases := []struct { |
| 67 | name string |
| 68 | ctx context.Context |
| 69 | output string |
| 70 | }{ |
| 71 | { |
| 72 | name: "background context", |
| 73 | ctx: context.Background(), |
| 74 | output: "[INF] foobar\n", |
| 75 | }, |
| 76 | { |
| 77 | name: "empty LogContext context", |
| 78 | ctx: LogContextWith(context.Background(), &LogContext{}), |
| 79 | output: "[INF] foobar\n", |
| 80 | }, |
| 81 | { |
| 82 | name: "test context", |
| 83 | ctx: TestCtx(t), |
| 84 | output: "[INF] t:TestLogFormat foobar\n", |
| 85 | }, |
| 86 | { |
| 87 | name: "bucket only no database", |
| 88 | ctx: LogContextWith(context.Background(), &LogContext{ |
| 89 | Bucket: "testBucket", |
| 90 | }), |
| 91 | output: "[INF] b:testBucket foobar\n", |
| 92 | }, |
| 93 | { |
| 94 | name: "test and bucket only no database", |
| 95 | ctx: BucketNameCtx(TestCtx(t), "testBucket"), |
| 96 | output: "[INF] t:TestLogFormat b:testBucket foobar\n", |
| 97 | }, |
| 98 | |
| 99 | { |
| 100 | name: "full keyspace, no database", |
| 101 | ctx: LogContextWith(context.Background(), &LogContext{ |
| 102 | Bucket: "testBucket", |
| 103 | Collection: "testCollection", |
| 104 | Scope: "testScope", |
| 105 | }), |
| 106 | output: "[INF] b:testBucket.testScope.testCollection foobar\n", |
| 107 | }, |
| 108 | { |
| 109 | name: "partial keyspace, no database", |
| 110 | ctx: LogContextWith(context.Background(), &LogContext{ |
| 111 | Bucket: "testBucket", |
| 112 | Collection: "testCollection", |
| 113 | }), |
| 114 | output: "[INF] b:testBucket.testCollection foobar\n", |
| 115 | }, |
| 116 | { |
| 117 | name: "database only", |
| 118 | ctx: LogContextWith(context.Background(), &LogContext{ |
| 119 | Database: "dbName", |
| 120 | }), |
| 121 | output: "[INF] db:dbName foobar\n", |
| 122 | }, |
nothing calls this directly
no test coverage detected