use zerolog for integrationtests too

This commit is contained in:
6543 2022-06-10 19:47:52 +02:00
parent de9c37d72b
commit 50df84eec9
2 changed files with 9 additions and 8 deletions

View file

@ -4,16 +4,16 @@ import (
"bytes" "bytes"
"crypto/tls" "crypto/tls"
"io" "io"
"log"
"net/http" "net/http"
"net/http/cookiejar" "net/http/cookiejar"
"testing" "testing"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestGetRedirect(t *testing.T) { func TestGetRedirect(t *testing.T) {
log.Println("== TestGetRedirect ==") log.Printf("== TestGetRedirect ==\n")
// test custom domain redirect // test custom domain redirect
resp, err := getTestHTTPSClient().Get("https://calciumdibromid.localhost.mock.directory:4430") resp, err := getTestHTTPSClient().Get("https://calciumdibromid.localhost.mock.directory:4430")
assert.NoError(t, err) assert.NoError(t, err)
@ -25,7 +25,7 @@ func TestGetRedirect(t *testing.T) {
} }
func TestGetContent(t *testing.T) { func TestGetContent(t *testing.T) {
log.Println("== TestGetContent ==") log.Printf("== TestGetContent ==\n")
// test get image // test get image
resp, err := getTestHTTPSClient().Get("https://magiclike.localhost.mock.directory:4430/images/827679288a.jpg") resp, err := getTestHTTPSClient().Get("https://magiclike.localhost.mock.directory:4430/images/827679288a.jpg")
assert.NoError(t, err) assert.NoError(t, err)

View file

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