-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbrowser_pools_test.go
More file actions
72 lines (57 loc) · 2.5 KB
/
browser_pools_test.go
File metadata and controls
72 lines (57 loc) · 2.5 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package cmd
import (
"context"
"testing"
"github.com/kernel/kernel-go-sdk"
"github.com/kernel/kernel-go-sdk/option"
"github.com/stretchr/testify/assert"
)
type fakeBrowserPoolsService struct {
newFunc func(ctx context.Context, body kernel.BrowserPoolNewParams, opts ...option.RequestOption) (*kernel.BrowserPool, error)
}
func (f *fakeBrowserPoolsService) List(ctx context.Context, opts ...option.RequestOption) (*[]kernel.BrowserPool, error) {
return &[]kernel.BrowserPool{}, nil
}
func (f *fakeBrowserPoolsService) New(ctx context.Context, body kernel.BrowserPoolNewParams, opts ...option.RequestOption) (*kernel.BrowserPool, error) {
if f.newFunc != nil {
return f.newFunc(ctx, body, opts...)
}
return &kernel.BrowserPool{}, nil
}
func (f *fakeBrowserPoolsService) Get(ctx context.Context, id string, opts ...option.RequestOption) (*kernel.BrowserPool, error) {
return &kernel.BrowserPool{}, nil
}
func (f *fakeBrowserPoolsService) Update(ctx context.Context, id string, body kernel.BrowserPoolUpdateParams, opts ...option.RequestOption) (*kernel.BrowserPool, error) {
return &kernel.BrowserPool{}, nil
}
func (f *fakeBrowserPoolsService) Delete(ctx context.Context, id string, body kernel.BrowserPoolDeleteParams, opts ...option.RequestOption) error {
return nil
}
func (f *fakeBrowserPoolsService) Acquire(ctx context.Context, id string, body kernel.BrowserPoolAcquireParams, opts ...option.RequestOption) (*kernel.BrowserPoolAcquireResponse, error) {
return &kernel.BrowserPoolAcquireResponse{}, nil
}
func (f *fakeBrowserPoolsService) Release(ctx context.Context, id string, body kernel.BrowserPoolReleaseParams, opts ...option.RequestOption) error {
return nil
}
func (f *fakeBrowserPoolsService) Flush(ctx context.Context, id string, opts ...option.RequestOption) error {
return nil
}
func TestBrowserPoolsCreate_MapsChromePolicy(t *testing.T) {
setupStdoutCapture(t)
fake := &fakeBrowserPoolsService{
newFunc: func(ctx context.Context, body kernel.BrowserPoolNewParams, opts ...option.RequestOption) (*kernel.BrowserPool, error) {
assert.Equal(t, map[string]any{
"HomepageLocation": "https://example.com",
"ShowHomeButton": true,
}, body.ChromePolicy)
return &kernel.BrowserPool{ID: "pool_123", Name: "test-pool"}, nil
},
}
cmd := BrowserPoolsCmd{client: fake}
err := cmd.Create(context.Background(), BrowserPoolsCreateInput{
Name: "test-pool",
Size: 1,
ChromePolicy: `{"HomepageLocation":"https://example.com","ShowHomeButton":true}`,
})
assert.NoError(t, err)
}