--------------------------------------------------------------------------- helper unit tests ---------------------------------------------------------------------------
(t *testing.T)
| 651 | // --------------------------------------------------------------------------- |
| 652 | |
| 653 | func TestIsLocalFileSrc(t *testing.T) { |
| 654 | tests := []struct { |
| 655 | src string |
| 656 | want bool |
| 657 | }{ |
| 658 | {"./logo.png", true}, |
| 659 | {"../images/logo.png", true}, |
| 660 | {"logo.png", true}, |
| 661 | {"/absolute/path/logo.png", true}, |
| 662 | {`C:\images\logo.png`, false}, |
| 663 | {"C:/images/logo.png", false}, |
| 664 | {`c:\path\file.png`, false}, |
| 665 | {"cid:logo", false}, |
| 666 | {"CID:logo", false}, |
| 667 | {"http://example.com/img.png", false}, |
| 668 | {"https://example.com/img.png", false}, |
| 669 | {"data:image/png;base64,abc", false}, |
| 670 | {"//cdn.example.com/a.png", false}, |
| 671 | {"blob:https://example.com/uuid", false}, |
| 672 | {"ftp://example.com/file.png", false}, |
| 673 | {"file:///local/file.png", false}, |
| 674 | {"mailto:test@example.com", false}, |
| 675 | {"", false}, |
| 676 | } |
| 677 | for _, tt := range tests { |
| 678 | if got := isLocalFileSrc(tt.src); got != tt.want { |
| 679 | t.Errorf("isLocalFileSrc(%q) = %v, want %v", tt.src, got, tt.want) |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | func TestGenerateCID(t *testing.T) { |
| 685 | seen := make(map[string]bool) |
nothing calls this directly
no test coverage detected