-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport_test.go
58 lines (50 loc) · 1.32 KB
/
export_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2017 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package resource
import (
"time"
"github.com/juju/charm/v12"
"github.com/juju/names/v5"
"github.com/juju/juju/state"
)
func NewCSRetryClientForTest(client ResourceGetter) *ResourceRetryClient {
retryClient := newRetryClient(client)
// Reduce retry delay for test.
retryClient.retryArgs.Delay = 1 * time.Millisecond
return retryClient
}
func NewCharmHubClientForTest(cl CharmHub, logger Logger) *CharmHubClient {
return &CharmHubClient{
client: cl,
logger: logger,
}
}
func NewResourceRetryClientForTest(cl ResourceGetter) *ResourceRetryClient {
client := newRetryClient(cl)
client.retryArgs.Delay = time.Millisecond
return client
}
func NewResourceOpenerForTest(
res Resources,
tag names.Tag,
unitName string,
appName string,
charmURL *charm.URL,
charmOrigin state.CharmOrigin,
resourceClient ResourceGetter,
resourceDownloadLimiter ResourceDownloadLock,
) *ResourceOpener {
return &ResourceOpener{
modelUUID: "uuid",
resourceCache: res,
user: tag,
unitName: unitName,
appName: appName,
charmURL: charmURL,
charmOrigin: charmOrigin,
resourceClient: resourceClient,
resourceDownloadLimiterFunc: func() ResourceDownloadLock {
return resourceDownloadLimiter
},
}
}