forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_config.go
42 lines (35 loc) · 967 Bytes
/
test_config.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
package configuration
import (
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
"code.cloudfoundry.org/cli/cf/models"
)
func NewRepository() coreconfig.Repository {
return coreconfig.NewRepositoryFromPersistor(NewFakePersistor(), func(err error) {
panic(err)
})
}
func NewRepositoryWithAccessToken(tokenInfo coreconfig.TokenInfo) coreconfig.Repository {
accessToken, err := EncodeAccessToken(tokenInfo)
if err != nil {
panic(err)
}
config := NewRepository()
config.SetAccessToken(accessToken)
return config
}
func NewRepositoryWithDefaults() coreconfig.Repository {
configRepo := NewRepositoryWithAccessToken(coreconfig.TokenInfo{
UserGUID: "my-user-guid",
Username: "my-user",
Email: "my-user-email",
})
configRepo.SetSpaceFields(models.SpaceFields{
Name: "my-space",
GUID: "my-space-guid",
})
configRepo.SetOrganizationFields(models.OrganizationFields{
Name: "my-org",
GUID: "my-org-guid",
})
return configRepo
}