(t *testing.T)
| 256 | } |
| 257 | |
| 258 | func TestAttachmentForRejectedDocument(t *testing.T) { |
| 259 | db, ctx := setupTestDB(t) |
| 260 | defer db.Close(ctx) |
| 261 | |
| 262 | collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db) |
| 263 | collection.ChannelMapper = channels.NewChannelMapper(ctx, |
| 264 | `function(doc, oldDoc) { |
| 265 | throw({forbidden: "None shall pass!"}); |
| 266 | }`, db.Options.JavascriptTimeout) |
| 267 | |
| 268 | docBody := `{"_attachments": {"hello.txt": {"data":"aGVsbG8gd29ybGQ="}}}` |
| 269 | var body Body |
| 270 | require.NoError(t, base.JSONUnmarshal([]byte(docBody), &body)) |
| 271 | _, _, err := collection.Put(ctx, "doc1", unmarshalBody(t, docBody)) |
| 272 | require.Error(t, err) |
| 273 | |
| 274 | // Attempt to retrieve the attachment doc |
| 275 | _, _, err = db.Bucket.DefaultDataStore().GetRaw(base.AttPrefix + "sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0=") |
| 276 | require.Error(t, err, "Expected error when attempting to retrieve attachment document after doc is rejected.") |
| 277 | } |
| 278 | |
| 279 | func TestAttachmentRetrievalUsingRevCache(t *testing.T) { |
| 280 | db, ctx := setupTestDB(t) |
nothing calls this directly
no test coverage detected