Merge branch 'main' into move-more-logic-into-client

This commit is contained in:
6543 2022-08-12 05:09:34 +02:00
commit bddb4b9c5f
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE
12 changed files with 107 additions and 92 deletions

View file

@ -7,17 +7,17 @@ import (
"bytes"
"crypto/tls"
"io"
"log"
"net/http"
"net/http/cookiejar"
"strings"
"testing"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
)
func TestGetRedirect(t *testing.T) {
log.Printf("=== TestGetRedirect ===\n")
log.Println("=== TestGetRedirect ===")
// test custom domain redirect
resp, err := getTestHTTPSClient().Get("https://calciumdibromid.localhost.mock.directory:4430")
assert.NoError(t, err)
@ -29,7 +29,7 @@ func TestGetRedirect(t *testing.T) {
}
func TestGetContent(t *testing.T) {
log.Printf("=== TestGetContent ===\n")
log.Println("=== TestGetContent ===")
// test get image
resp, err := getTestHTTPSClient().Get("https://magiclike.localhost.mock.directory:4430/images/827679288a.jpg")
assert.NoError(t, err)
@ -65,7 +65,7 @@ func TestGetContent(t *testing.T) {
}
func TestCustomDomain(t *testing.T) {
log.Printf("=== TestCustomDomain ===\n")
log.Println("=== TestCustomDomain ===")
resp, err := getTestHTTPSClient().Get("https://mock-pages.codeberg-test.org:4430/README.md")
assert.NoError(t, err)
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
@ -77,7 +77,7 @@ func TestCustomDomain(t *testing.T) {
}
func TestGetNotFound(t *testing.T) {
log.Printf("=== TestGetNotFound ===\n")
log.Println("=== TestGetNotFound ===")
// test custom not found pages
resp, err := getTestHTTPSClient().Get("https://crystal.localhost.mock.directory:4430/pages-404-demo/blah")
assert.NoError(t, err)

View file

@ -5,25 +5,25 @@ package integration
import (
"context"
"log"
"os"
"testing"
"time"
"codeberg.org/codeberg/pages/cmd"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
)
func TestMain(m *testing.M) {
log.Printf("=== TestMain: START Server ===\n")
log.Println("=== TestMain: START Server ===")
serverCtx, serverCancel := context.WithCancel(context.Background())
if err := startServer(serverCtx); err != nil {
log.Fatal().Msgf("could not start server: %v", err)
log.Fatalf("could not start server: %v", err)
}
defer func() {
serverCancel()
log.Printf("=== TestMain: Server STOPED ===\n")
log.Println("=== TestMain: Server STOPED ===")
}()
time.Sleep(10 * time.Second)
@ -48,7 +48,7 @@ func startServer(ctx context.Context) error {
go func() {
if err := app.RunContext(ctx, args); err != nil {
log.Fatal().Msgf("run server error: %v", err)
log.Fatalf("run server error: %v", err)
}
}()