TestBootstrapDuplicateBucket will attempt to create two databases sharing the same collections and ensure this isn't allowed.
(t *testing.T)
| 117 | |
| 118 | // TestBootstrapDuplicateBucket will attempt to create two databases sharing the same collections and ensure this isn't allowed. |
| 119 | func TestBootstrapDuplicateCollections(t *testing.T) { |
| 120 | base.SetUpTestLogging(t, base.LevelInfo, base.KeyHTTP) |
| 121 | |
| 122 | sc, closeFn := StartBootstrapServer(t) |
| 123 | defer closeFn() |
| 124 | |
| 125 | ctx := base.TestCtx(t) |
| 126 | |
| 127 | // Get a test bucket, and use it to create the database. |
| 128 | tb := base.GetTestBucket(t) |
| 129 | defer tb.Close(ctx) |
| 130 | resp := BootstrapAdminRequest(t, sc, http.MethodPut, "/db1/", |
| 131 | fmt.Sprintf( |
| 132 | `{"bucket": "%s", "num_index_replicas": 0, "enable_shared_bucket_access": %t, "use_views": %t}`, |
| 133 | tb.GetName(), base.TestUseXattrs(), base.TestsDisableGSI(), |
| 134 | ), |
| 135 | ) |
| 136 | resp.RequireStatus(http.StatusCreated) |
| 137 | |
| 138 | // Create db2 using the same collection (on the same bucket) and expect it to fail |
| 139 | resp = BootstrapAdminRequest(t, sc, http.MethodPut, "/db2/", |
| 140 | fmt.Sprintf( |
| 141 | `{"bucket": "%s", "num_index_replicas": 0, "enable_shared_bucket_access": %t, "use_views": %t}`, |
| 142 | tb.GetName(), base.TestUseXattrs(), base.TestsDisableGSI(), |
| 143 | ), |
| 144 | ) |
| 145 | resp.RequireStatus(http.StatusConflict) |
| 146 | } |
| 147 | |
| 148 | // TestBootstrapDuplicateDatabase will attempt to create a second database and ensure this isn't allowed. |
| 149 | func TestBootstrapDuplicateDatabase(t *testing.T) { |
nothing calls this directly
no test coverage detected