// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package servertest // import "miniflux.app/v2/internal/http/server/servertest"
import (
"bytes"
"fmt"
"image"
"image/color"
"image/png"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
miniflux "miniflux.app/v2/client"
)
const (
FeedTitle = "Integration Test Feed"
SubscriptionTitle = "Integration Test Subscription"
EntryCount = 3
// SearchTerm appears only in the content of the second entry.
SearchTerm = "zanzibar"
// ArticleText appears in every article page, but not in the feed.
ArticleText = "This paragraph only exists on the original article page."
)
// FeedFixture is a local website with a feed, an icon and article pages.
// The server under test fetches it instead of a remote site.
type FeedFixture struct {
WebsiteURL string
FeedURL string
}
// NewFeedFixture starts a fixture website that is shut down when the test ends.
func NewFeedFixture(t testing.TB) *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, `