-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtext_to_image_test.go
41 lines (37 loc) · 944 Bytes
/
text_to_image_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package hfapigo_test
import (
"testing"
"github.com/Kardbord/hfapigo/v3"
)
func TestTextToImage(t *testing.T) {
{ // Test valid request
img, fmt, err := hfapigo.SendTextToImageRequest(hfapigo.RecommendedTextToImageModel, &hfapigo.TextToImageRequest{
Inputs: "A dog and a cat sleeping adorably.",
Options: *hfapigo.NewOptions().SetWaitForModel(true),
})
if err != nil {
t.Fatal(err)
}
if fmt == "" {
t.Fatal("empty encoding returned")
}
if img == nil {
t.Fatal("nil image returned")
}
}
{ // Test invalid request
img, fmt, err := hfapigo.SendTextToImageRequest("not-a-model", &hfapigo.TextToImageRequest{
Inputs: "A dog and a cat sleeping adorably.",
Options: *hfapigo.NewOptions().SetWaitForModel(true),
})
if err == nil {
t.Fatal("expected an error")
}
if fmt != "" {
t.Fatal("expected an empty encoding string")
}
if img != nil {
t.Fatal("expected a nil image")
}
}
}