From ccd28fbd2bf9fe6fa0cbafcc81c5e39fdce807cd Mon Sep 17 00:00:00 2001 From: Chris Watson Date: Sat, 16 Nov 2024 19:50:00 -0700 Subject: [PATCH] more testing (commented) --- internal/server/services/types.go | 1 + internal/server/tests/paste_test.go | 30 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/internal/server/services/types.go b/internal/server/services/types.go index ee35086..85b0242 100644 --- a/internal/server/services/types.go +++ b/internal/server/services/types.go @@ -9,6 +9,7 @@ import ( // NewPasteOptions contains configuration options for creating a new paste type NewPasteOptions struct { + Content string // Content to be pasted Extension string // File extension (optional) ExpiresAt *time.Time // Expiration time for the paste Private bool // Whether the paste is private diff --git a/internal/server/tests/paste_test.go b/internal/server/tests/paste_test.go index e23c6ff..4d24afa 100644 --- a/internal/server/tests/paste_test.go +++ b/internal/server/tests/paste_test.go @@ -333,3 +333,33 @@ func TestRawPasteUpload(t *testing.T) { }) } } + +// func TestViewPaste(t *testing.T) { +// env := testutils.SetupTestEnv(t) +// defer env.CleanupFn() + +// // Create paste +// body := `{"content": "test content", "filename": "test.txt", "extension": "txt", "private": false}` +// req := httptest.NewRequest("POST", "/p/", strings.NewReader(body)) +// req.Header.Set("Content-Type", "application/json") + +// resp, err := env.App.Test(req) +// require.NoError(t, err) + +// // Parse response +// var paste services.NewPasteResponse +// err = json.NewDecoder(resp.Body).Decode(&paste) +// require.NoError(t, err) + +// fmt.Println(paste) + +// // View paste +// req = httptest.NewRequest("GET", fmt.Sprintf("/p/%s.txt", paste.ID), nil) +// resp, err = env.App.Test(req) +// require.NoError(t, err) + +// bodytext, _ := io.ReadAll(resp.Body) +// fmt.Println(string(bodytext)) + +// assert.Equal(t, 200, resp.StatusCode) +// }