-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathservices_render_test.go
More file actions
57 lines (52 loc) · 1.52 KB
/
services_render_test.go
File metadata and controls
57 lines (52 loc) · 1.52 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package octaspace
import (
"context"
"testing"
)
func TestRender_List(t *testing.T) {
want := []map[string]any{
{"uuid": "render-1", "status": "queued"},
{"uuid": "render-2", "status": "running"},
}
c, _ := newTestClient(t, jsonHandler(want))
got, err := c.Services.Render.List(context.Background(), nil)
if err != nil {
t.Fatalf("List: %v", err)
}
if len(got) != 2 {
t.Fatalf("len = %d, want 2", len(got))
}
if got[0]["uuid"] != "render-1" {
t.Errorf("got[0].uuid = %v, want render-1", got[0]["uuid"])
}
}
func TestRender_List_Error(t *testing.T) {
c, _ := newTestClient(t, statusHandler(401, `{"error":"unauthorized"}`))
_, err := c.Services.Render.List(context.Background(), nil)
if !IsAuthError(err) {
t.Errorf("expected AuthenticationError, got %T: %v", err, err)
}
}
func TestRender_Create(t *testing.T) {
want := map[string]any{"uuid": "created-render-uuid", "status": "queued"}
c, _ := newTestClient(t, jsonHandler(want))
got, err := c.Services.Render.Create(context.Background(), map[string]any{
"node_id": 42,
"image": "blender:latest",
})
if err != nil {
t.Fatalf("Create: %v", err)
}
if got["uuid"] != "created-render-uuid" {
t.Errorf("uuid = %v, want created-render-uuid", got["uuid"])
}
}
func TestRender_Create_Error(t *testing.T) {
c, _ := newTestClient(t, statusHandler(422, `{"error":"validation failed"}`))
_, err := c.Services.Render.Create(context.Background(), map[string]any{})
var valErr *ValidationError
if err == nil {
t.Fatal("expected error, got nil")
}
_ = valErr
}