~netlandish/links-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH links] Adding test to ensure export functionality is covered.

Details
Message ID
<20251230134544.3915-1-peter@netlandish.com>
Sender timestamp
1767080742
DKIM signature
missing
Download raw message
Patch: +83 -0
---
 core/routes_test.go | 83 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

diff --git a/core/routes_test.go b/core/routes_test.go
index 70eff34..3a98712 100644
--- a/core/routes_test.go
+++ b/core/routes_test.go
@@ -798,4 +798,87 @@ func TestHandlers(t *testing.T) {
		// Verify the form is shown (indicating error handling)
		c.True(len(htmlBody) > 0)
	})

	t.Run("export data", func(t *testing.T) {
		baseURL := &models.BaseURL{URL: "http://export-test.com"}
		err := baseURL.Store(dbCtx)
		c.NoError(err)

		orgLink := &models.OrgLink{
			Title:      "Export Test Link",
			URL:        "http://export-test.com",
			BaseURLID:  baseURL.ID,
			OrgID:      1,
			UserID:     1,
			Visibility: models.OrgLinkVisibilityPublic,
			Type:       models.OrgLinkType,
		}
		err = orgLink.Store(dbCtx)
		c.NoError(err)

		noteBaseURL := &models.BaseURL{URL: "http://export-note-test.com"}
		err = noteBaseURL.Store(dbCtx)
		c.NoError(err)

		note := &models.OrgLink{
			Title:      "Export Test Note",
			BaseURLID:  noteBaseURL.ID,
			OrgID:      1,
			UserID:     1,
			Type:       models.NoteType,
			Visibility: models.OrgLinkVisibilityPublic,
		}
		err = note.Store(dbCtx)
		c.NoError(err)

		linkShort := &models.LinkShort{
			Title:     "Export Test Short",
			URL:       "http://short-test.com",
			ShortCode: "exp1",
			DomainID:  1,
			OrgID:     1,
			UserID:    1,
		}
		err = linkShort.Store(dbCtx)
		c.NoError(err)

		listing := &models.Listing{
			Title:    "Export Test Listing",
			Slug:     "export-test-listing",
			DomainID: 2,
			OrgID:    1,
			UserID:   1,
			IsActive: true,
		}
		err = listing.Store(dbCtx)
		c.NoError(err)

		listingLink := &models.ListingLink{
			Title:     "Export Test Listing Link",
			ListingID: listing.ID,
			URL:       "http://listing-link-test.com",
			UserID:    1,
			LinkOrder: 1,
		}
		err = listingLink.Store(dbCtx)
		c.NoError(err)

		f := make(url.Values)
		f.Set("format", "0")
		request := httptest.NewRequest(http.MethodPost, "/personal-org/export", strings.NewReader(f.Encode()))
		request.Header.Set(echo.HeaderContentType, echo.MIMEApplicationForm)
		recorder := httptest.NewRecorder()
		ctx := &server.Context{
			Server:  srv,
			Context: e.NewContext(request, recorder),
			User:    loggedInUser,
		}
		ctx.SetPath("/:slug/export")
		ctx.SetParamNames("slug")
		ctx.SetParamValues("personal-org")
		err = test.MakeRequestWithDomain(srv, coreService.ExportData, ctx, domains[0])
		c.NoError(err)
		c.Equal(http.StatusOK, recorder.Code)
		c.Equal("application/json", recorder.Header().Get("Content-Type"))
	})
}
-- 
2.52.0
Details
Message ID
<DFBRVSRBG0RX.352CV378JZJU6@netlandish.com>
In-Reply-To
<20251230134544.3915-1-peter@netlandish.com> (view parent)
Sender timestamp
1767098747
DKIM signature
missing
Download raw message
Applied.

To git@git.code.netlandish.com:~netlandish/links
   6ddf2e8..e7d2ee2  master -> master
Reply to thread Export thread (mbox)