forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_config.go
41 lines (34 loc) · 949 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
package configuration
import (
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/models"
)
func NewRepository() configuration.Repository {
return configuration.NewRepositoryFromPersistor(NewFakePersistor(), func(err error) {
panic(err)
})
}
func NewRepositoryWithAccessToken(tokenInfo configuration.TokenInfo) configuration.Repository {
accessToken, err := EncodeAccessToken(tokenInfo)
if err != nil {
panic(err)
}
config := NewRepository()
config.SetAccessToken(accessToken)
return config
}
func NewRepositoryWithDefaults() configuration.Repository {
configRepo := NewRepositoryWithAccessToken(configuration.TokenInfo{
UserGuid: "my-user-guid",
Username: "my-user",
})
configRepo.SetSpaceFields(models.SpaceFields{
Name: "my-space",
Guid: "my-space-guid",
})
configRepo.SetOrganizationFields(models.OrganizationFields{
Name: "my-org",
Guid: "my-org-guid",
})
return configRepo
}