// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package api_test
import (
"bytes"
"fmt"
"image"
"image/color"
"image/png"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
miniflux "miniflux.app/v2/client"
)
const (
fixtureFeedTitle = "Integration Test Feed"
fixtureSubscriptionTitle = "Integration Test Subscription"
fixtureEntryCount = 3
// fixtureSearchTerm appears only in the content of the second entry.
fixtureSearchTerm = "zanzibar"
// fixtureArticleText appears in every article page, but not in the feed.
fixtureArticleText = "This paragraph only exists on the original article page."
)
// feedFixture is a local website with a feed, an icon and article pages.
// The Miniflux server under test fetches it instead of a remote site,
// which requires FETCHER_ALLOW_PRIVATE_NETWORKS=1.
type feedFixture struct {
websiteURL string
feedURL string
}
// newFeedFixture starts a fixture website that is shut down when the test ends.
func newFeedFixture(t *testing.T) *feedFixture {
t.Helper()
icon := newFixtureIcon(t)
mux := http.NewServeMux()
server := httptest.NewServer(mux)
t.Cleanup(server.Close)
fixture := &feedFixture{
websiteURL: server.URL + "/",
feedURL: server.URL + "/feed.xml",
}
mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintf(w, `