(t *testing.T)
| 23 | } |
| 24 | |
| 25 | func TestLoadImageAttachment_PNG(t *testing.T) { |
| 26 | dir := t.TempDir() |
| 27 | p := filepath.Join(dir, "pic.png") |
| 28 | if err := os.WriteFile(p, testPNG, 0o600); err != nil { |
| 29 | t.Fatal(err) |
| 30 | } |
| 31 | img, ok := testCLI().loadImageAttachment(p) |
| 32 | if !ok { |
| 33 | t.Fatal("expected PNG to be recognized as an image attachment") |
| 34 | } |
| 35 | if img.MediaType != "image/png" { |
| 36 | t.Fatalf("media type = %q, want image/png", img.MediaType) |
| 37 | } |
| 38 | if len(img.Data) != len(testPNG) { |
| 39 | t.Fatalf("data len = %d, want %d", len(img.Data), len(testPNG)) |
| 40 | } |
| 41 | if img.FileName != "pic.png" { |
| 42 | t.Fatalf("filename = %q, want pic.png", img.FileName) |
| 43 | } |
| 44 | if !img.IsValid() { |
| 45 | t.Fatal("attachment should be valid") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestLoadImageAttachment_RejectsTextAndDir(t *testing.T) { |
| 50 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected