feat(worker): add centered 128x128 JPEG crop
This commit is contained in:
@@ -155,6 +155,11 @@ func TestWorkerPersistenceAndDuplicate(t *testing.T) {
|
||||
if err != nil || cfg.Width != 256 || cfg.Height != 160 {
|
||||
t.Fatal("invalid JPEG thumbnail")
|
||||
}
|
||||
crop := workerContent(t, user, att.ID, "crop")
|
||||
cfg, err = jpeg.DecodeConfig(bytes.NewReader(crop))
|
||||
if err != nil || cfg.Width != 128 || cfg.Height != 128 {
|
||||
t.Fatal("invalid JPEG crop")
|
||||
}
|
||||
// Re-publish the same intent, modeling duplicate delivery after a lost publisher confirmation.
|
||||
workerSQL(t, "UPDATE outbox SET published_at=NULL WHERE "+where)
|
||||
workerWait(t, "duplicate publication", 15*time.Second, func() bool {
|
||||
@@ -162,10 +167,11 @@ func TestWorkerPersistenceAndDuplicate(t *testing.T) {
|
||||
})
|
||||
workerWait(t, "duplicate acknowledgement", 15*time.Second, func() bool { return workerQueue(t) == "0:0" })
|
||||
duplicate := waitAttachment(t, user, att.ID, "ready", 30*time.Second)
|
||||
if !reflect.DeepEqual(ready, duplicate) || workerSQL(t, "SELECT count(*) FROM attachment_variants WHERE "+where) != "1" {
|
||||
if !reflect.DeepEqual(ready, duplicate) || workerSQL(t, "SELECT count(*) FROM attachment_variants WHERE "+where) != "2" {
|
||||
t.Fatal("duplicate job changed metadata or duplicated variants")
|
||||
}
|
||||
if !bytes.Equal(workerContent(t, user, att.ID, "thumbnail"), thumb) ||
|
||||
if !bytes.Equal(workerContent(t, user, att.ID, "crop"), crop) ||
|
||||
!bytes.Equal(workerContent(t, user, att.ID, "thumbnail"), thumb) ||
|
||||
!bytes.Equal(workerContent(t, user, att.ID, "original"), source) {
|
||||
t.Fatal("duplicate changed content")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user