feat(files): implement file storage functionality with save, load, and list operations
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"git.warky.dev/wdevs/amcs/internal/config"
|
||||
thoughttypes "git.warky.dev/wdevs/amcs/internal/types"
|
||||
)
|
||||
@@ -79,3 +81,24 @@ func TestMergeAddsPatchAndNormalizes(t *testing.T) {
|
||||
t.Fatalf("Topics len = %d, want 2", len(got.Topics))
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeDedupesAttachmentsByFileID(t *testing.T) {
|
||||
id := uuid.New()
|
||||
|
||||
got := Normalize(thoughttypes.ThoughtMetadata{
|
||||
Attachments: []thoughttypes.ThoughtAttachment{
|
||||
{FileID: id, Name: " one.png ", MediaType: " image/png ", Kind: " image ", SizeBytes: 12, SHA256: " abc "},
|
||||
{FileID: id, Name: "two.png", MediaType: "image/png", Kind: "image", SizeBytes: 99, SHA256: "def"},
|
||||
},
|
||||
}, testCaptureConfig())
|
||||
|
||||
if len(got.Attachments) != 1 {
|
||||
t.Fatalf("Attachments len = %d, want 1", len(got.Attachments))
|
||||
}
|
||||
if got.Attachments[0].Name != "one.png" {
|
||||
t.Fatalf("Attachment name = %q, want one.png", got.Attachments[0].Name)
|
||||
}
|
||||
if got.Attachments[0].Kind != "image" {
|
||||
t.Fatalf("Attachment kind = %q, want image", got.Attachments[0].Kind)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user