Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

639 B
Raw Blame
package framework

import (
	"io"
	"net/http"
	"testing"
	"time"
)

func NewHTTPClient() *http.Client {
	return &http.Client{Timeout: 10 * time.Second}
}

func DoRequest(t testing.TB, client *http.Client, req *http.Request) *http.Response {
	t.Helper()
	resp, err := client.Do(req)
	if err != nil {
		t.Fatalf("http request %s %s: %v", req.Method, req.URL.String(), err)
	}
	return resp
}

func ReadAllAndClose(t testing.TB, resp *http.Response) []byte {
	t.Helper()
	if resp == nil {
		return nil
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		t.Fatalf("read response body: %v", err)
	}
	return body
}