MCPcopy Create free account
hub / github.com/diillson/chatcli / TestLoadImageAttachment_PNG

Function TestLoadImageAttachment_PNG

cli/cli_file_processing_image_test.go:25–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func 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
49func TestLoadImageAttachment_RejectsTextAndDir(t *testing.T) {
50 dir := t.TempDir()

Callers

nothing calls this directly

Calls 3

testCLIFunction · 0.85
loadImageAttachmentMethod · 0.80
IsValidMethod · 0.45

Tested by

no test coverage detected