Files
backend/tests/02_postImage_test.go
Yi-Ting Shih 0fc8f1f08c
All checks were successful
Go test / run-go-vet (push) Successful in 5s
Go test / run-go-test (push) Successful in 22s
Go test / cleanup-go-test (push) Successful in 4s
Go test / check-swagger-up-to-date (push) Successful in 9s
Go test / release-image (push) Successful in 3m22s
Fix: broken ci and tests
2025-12-13 02:45:33 +08:00

38 lines
643 B
Go

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("/api/image")
if err != nil || resp.StatusCode() != http.StatusOK {
t.Logf("%+v", resp)
t.Fatal("failed to post image")
}
}