summaryrefslogtreecommitdiffstats
path: root/internal/compose/mime_test.go
diff options
context:
space:
mode:
authorGab Virebent <gabriel1@virebent.art>2026-08-22 20:36:56 +0200
committerGab Virebent <gabriel1@virebent.art>2026-08-22 20:36:56 +0200
commitc1decadb590c4d79d92bcc4df7772119a5c91244 (patch)
tree468f9fa37535dbb90cc5d4061eb20de83912131e /internal/compose/mime_test.go
downloadaegis-c1decadb590c4d79d92bcc4df7772119a5c91244.tar.gz
aegis-c1decadb590c4d79d92bcc4df7772119a5c91244.tar.xz
aegis-c1decadb590c4d79d92bcc4df7772119a5c91244.zip
Initial Aegis Usenet client release
Diffstat (limited to 'internal/compose/mime_test.go')
-rw-r--r--internal/compose/mime_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/compose/mime_test.go b/internal/compose/mime_test.go
new file mode 100644
index 0000000..32fb6b2
--- /dev/null
+++ b/internal/compose/mime_test.go
@@ -0,0 +1,31 @@
+package compose
+
+import (
+ "mime"
+ "strings"
+ "testing"
+)
+
+func TestBuildMixed(t *testing.T) {
+ contentType, transfer, body, err := BuildMixed("ciao\nmondo", []Attachment{{Filename: "hello.txt", Data: []byte("hello")}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mediaType, params, err := mime.ParseMediaType(contentType)
+ if err != nil || mediaType != "multipart/mixed" || params["boundary"] == "" || transfer != "7bit" {
+ t.Fatalf("unexpected MIME metadata: %q, %q, %v", contentType, transfer, err)
+ }
+ if !strings.Contains(body, "Content-Disposition: attachment") || !strings.Contains(body, "aGVsbG8=") {
+ t.Fatalf("attachment missing: %q", body)
+ }
+}
+
+func TestBuildOpenPGPMIME(t *testing.T) {
+ contentType, _, body, err := BuildOpenPGPMIME("-----BEGIN PGP MESSAGE-----\nabc\n-----END PGP MESSAGE-----")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.HasPrefix(contentType, "multipart/encrypted") || !strings.Contains(body, "Version: 1") || !strings.Contains(body, "BEGIN PGP MESSAGE") {
+ t.Fatalf("invalid OpenPGP/MIME body: %q", body)
+ }
+}