MCPcopy
hub / github.com/usememos/memos / TestAttachmentNeedsInstanceStorageSetting

Function TestAttachmentNeedsInstanceStorageSetting

store/test/attachment_test.go:15–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestAttachmentNeedsInstanceStorageSetting(t *testing.T) {
16 tests := []struct {
17 name string
18 attachment *store.Attachment
19 want bool
20 }{
21 {
22 name: "nil attachment",
23 },
24 {
25 name: "local attachment",
26 attachment: &store.Attachment{
27 StorageType: storepb.AttachmentStorageType_LOCAL,
28 },
29 },
30 {
31 name: "s3 attachment without payload",
32 attachment: &store.Attachment{
33 StorageType: storepb.AttachmentStorageType_S3,
34 },
35 },
36 {
37 name: "s3 attachment with embedded config",
38 attachment: &store.Attachment{
39 StorageType: storepb.AttachmentStorageType_S3,
40 Payload: &storepb.AttachmentPayload{
41 Payload: &storepb.AttachmentPayload_S3Object_{
42 S3Object: &storepb.AttachmentPayload_S3Object{
43 S3Config: &storepb.StorageS3Config{},
44 },
45 },
46 },
47 },
48 },
49 {
50 name: "s3 attachment without embedded config",
51 attachment: &store.Attachment{
52 StorageType: storepb.AttachmentStorageType_S3,
53 Payload: &storepb.AttachmentPayload{
54 Payload: &storepb.AttachmentPayload_S3Object_{
55 S3Object: &storepb.AttachmentPayload_S3Object{},
56 },
57 },
58 },
59 want: true,
60 },
61 }
62
63 for _, test := range tests {
64 t.Run(test.name, func(t *testing.T) {
65 if got := store.AttachmentNeedsInstanceStorageSetting(test.attachment); got != test.want {
66 t.Fatalf("AttachmentNeedsInstanceStorageSetting() = %v, want %v", got, test.want)
67 }
68 })
69 }
70}
71
72func TestAttachmentStore(t *testing.T) {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65

Tested by

no test coverage detected