Feat: add more tests

This commit is contained in:
2025-12-07 23:59:24 +08:00
parent 1f313fc17d
commit f191aef810
17 changed files with 307 additions and 25 deletions

View File

@@ -0,0 +1,37 @@
package tests
import (
"io"
"net/http"
"os"
"testing"
)
type postImagePayload struct {
Id int64 `json:"id"`
Extension string `json:"extension"`
}
var rawImage []byte
var image postImagePayload
func Test_02_PostImage(t *testing.T) {
f, err := os.Open("resources/huh.png")
if err != nil {
t.Fatal("failed to open test png")
}
rawImage, err = io.ReadAll(f)
if err != nil {
t.Fatal("failed to read from file")
}
resp, err := client.R().
SetBody(rawImage).
SetResult(&image).
Post("http://localhost:8080/api/image")
if err != nil || resp.StatusCode() != http.StatusOK {
t.Logf("%+v", resp)
t.Fatal("failed to post image")
}
}