github.com/abhinav/git-fu@v0.6.1-0.20171029234004-54218d68c11b/cli/clitest/config.go (about) 1 package clitest 2 3 import ( 4 "github.com/abhinav/git-pr/cli" 5 "github.com/abhinav/git-pr/gateway" 6 "github.com/abhinav/git-pr/repo" 7 ) 8 9 // ConfigBuilder may be used to build a cli.Config from static values. 10 type ConfigBuilder struct { 11 Git gateway.Git 12 Repo *repo.Repo 13 GitHub gateway.GitHub 14 GitHubUser string 15 } 16 17 // Build the cli.Config. This function may also be used as a 18 // cli.ConfigBuilder. 19 func (c *ConfigBuilder) Build() (cli.Config, error) { 20 // We never return an error. It's used only to satisfy the 21 // cli.ConfigBuilder signature. 22 return &config{*c}, nil 23 } 24 25 type config struct{ data ConfigBuilder } 26 27 func (c *config) Git() gateway.Git { 28 return c.data.Git 29 } 30 31 func (c *config) Repo() *repo.Repo { 32 return c.data.Repo 33 } 34 35 func (c *config) CurrentGitHubUser() string { 36 return c.data.GitHubUser 37 } 38 39 func (c *config) GitHub() gateway.GitHub { 40 return c.data.GitHub 41 }