github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/util/testhelpers/configuration/test_config.go (about)

     1  package configuration
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
     5  	"code.cloudfoundry.org/cli/cf/models"
     6  )
     7  
     8  func NewRepository() coreconfig.Repository {
     9  	return coreconfig.NewRepositoryFromPersistor(NewFakePersistor(), func(err error) {
    10  		panic(err)
    11  	})
    12  }
    13  
    14  func NewRepositoryWithAccessToken(tokenInfo coreconfig.TokenInfo) coreconfig.Repository {
    15  	accessToken, err := EncodeAccessToken(tokenInfo)
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	config := NewRepository()
    21  	config.SetAccessToken(accessToken)
    22  	return config
    23  }
    24  
    25  func NewRepositoryWithDefaults() coreconfig.Repository {
    26  	configRepo := NewRepositoryWithAccessToken(coreconfig.TokenInfo{
    27  		UserGUID: "my-user-guid",
    28  		Username: "my-user",
    29  		Email:    "my-user-email",
    30  	})
    31  
    32  	configRepo.SetSpaceFields(models.SpaceFields{
    33  		Name: "my-space",
    34  		GUID: "my-space-guid",
    35  	})
    36  	configRepo.SetOrganizationFields(models.OrganizationFields{
    37  		Name: "my-org",
    38  		GUID: "my-org-guid",
    39  	})
    40  
    41  	return configRepo
    42  }