-
Notifications
You must be signed in to change notification settings - Fork 251
/
factory.go
71 lines (59 loc) · 2.11 KB
/
factory.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
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
package mocktc
import (
"testing"
tcclient "github.com/taskcluster/taskcluster/v60/clients/client-go"
"github.com/taskcluster/taskcluster/v60/clients/client-go/tcauth"
"github.com/taskcluster/taskcluster/v60/clients/client-go/tcindex"
"github.com/taskcluster/taskcluster/v60/clients/client-go/tcobject"
"github.com/taskcluster/taskcluster/v60/clients/client-go/tcqueue"
"github.com/taskcluster/taskcluster/v60/clients/client-go/tcsecrets"
"github.com/taskcluster/taskcluster/v60/clients/client-go/tcworkermanager"
"github.com/taskcluster/taskcluster/v60/internal/mocktc/tc"
)
type ServiceFactory struct {
auth tc.Auth
queue tc.Queue
index tc.Index
secrets tc.Secrets
purgeCache tc.PurgeCache
workerManager tc.WorkerManager
object tc.Object
}
func NewServiceFactory(t *testing.T) *ServiceFactory {
t.Helper()
creds := &tcclient.Credentials{
ClientID: "test-client-id",
AccessToken: "test-access-token",
}
rootURL := "http://localhost:13243"
return &ServiceFactory{
auth: tcauth.New(creds, rootURL),
index: tcindex.New(creds, rootURL),
queue: tcqueue.New(creds, rootURL),
secrets: tcsecrets.New(creds, rootURL),
purgeCache: NewPurgeCache(t),
workerManager: tcworkermanager.New(creds, rootURL),
object: tcobject.New(creds, rootURL),
}
}
func (sf *ServiceFactory) Auth(creds *tcclient.Credentials, rootURL string) tc.Auth {
return sf.auth
}
func (sf *ServiceFactory) Index(creds *tcclient.Credentials, rootURL string) tc.Index {
return sf.index
}
func (sf *ServiceFactory) Queue(creds *tcclient.Credentials, rootURL string) tc.Queue {
return sf.queue
}
func (sf *ServiceFactory) Secrets(creds *tcclient.Credentials, rootURL string) tc.Secrets {
return sf.secrets
}
func (sf *ServiceFactory) PurgeCache(creds *tcclient.Credentials, rootURL string) tc.PurgeCache {
return sf.purgeCache
}
func (sf *ServiceFactory) WorkerManager(creds *tcclient.Credentials, rootURL string) tc.WorkerManager {
return sf.workerManager
}
func (sf *ServiceFactory) Object(creds *tcclient.Credentials, rootURL string) tc.Object {
return sf.object
}