From d0bfcea59d0a3927db4d781d4cb15d6d192820b2 Mon Sep 17 00:00:00 2001 From: Johnlon <836248+Johnlon@users.noreply.github.com> Date: Fri, 28 Jun 2024 20:17:23 +0100 Subject: [PATCH] added some more tests for attachments --- attachment_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 attachment_test.go diff --git a/attachment_test.go b/attachment_test.go new file mode 100644 index 00000000..eb81055e --- /dev/null +++ b/attachment_test.go @@ -0,0 +1,28 @@ +package godog + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestAttach(t *testing.T) { + + ctx := context.Background() + + ctx = Attach(ctx, Attachment{Body: []byte("body1"), FileName: "fileName1", MediaType: "mediaType1"}) + ctx = Attach(ctx, Attachment{Body: []byte("body2"), FileName: "fileName2", MediaType: "mediaType2"}) + + attachments := Attachments(ctx) + + assert.Equal(t, 2, len(attachments)) + + assert.Equal(t, []byte("body1"), attachments[0].Body) + assert.Equal(t, "fileName1", attachments[0].FileName) + assert.Equal(t, "mediaType1", attachments[0].MediaType) + + assert.Equal(t, []byte("body2"), attachments[1].Body) + assert.Equal(t, "fileName2", attachments[1].FileName) + assert.Equal(t, "mediaType2", attachments[1].MediaType) +}