test(config,git,logger): add some test functions
This commit is contained in:
parent
316e5de757
commit
1356128a7b
16 changed files with 387 additions and 25 deletions
|
@ -7,6 +7,15 @@ import (
|
|||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidGrafanaURL = errors.New("invalid grafana URL, must not be blank")
|
||||
ErrInvalidAuthToken = errors.New("invalid auth token for grafana, must not be blank")
|
||||
ErrInvalidRepoURL = errors.New("invalid repo url for git, must not be blank")
|
||||
ErrInvalidGitUser = errors.New("invalid username for git, must not be blank")
|
||||
ErrInvalidGitPass = errors.New("invalid password for git, must not be blank")
|
||||
ErrInvalidBranchName = errors.New("invalid branch name for git, must not be blank")
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Debug bool
|
||||
ForceCommits bool
|
||||
|
@ -29,27 +38,27 @@ func (c *Config) Validate() []error {
|
|||
var errs []error
|
||||
|
||||
if c.GrafanaURL == "" {
|
||||
errs = append(errs, errors.New("invalid grafana URL, must not be blank"))
|
||||
errs = append(errs, ErrInvalidGrafanaURL)
|
||||
}
|
||||
|
||||
if c.GrafanaToken == "" {
|
||||
errs = append(errs, errors.New("invalid auth token for grafana, must not be blank"))
|
||||
errs = append(errs, ErrInvalidAuthToken)
|
||||
}
|
||||
|
||||
if c.GitRepo == "" {
|
||||
errs = append(errs, errors.New("invalid repo url for git, must not be blank"))
|
||||
errs = append(errs, ErrInvalidRepoURL)
|
||||
}
|
||||
|
||||
if c.GitUser == "" {
|
||||
errs = append(errs, errors.New("invalid username for git, must not be blank"))
|
||||
errs = append(errs, ErrInvalidGitUser)
|
||||
}
|
||||
|
||||
if c.GitPass == "" {
|
||||
errs = append(errs, errors.New("invalid password for git, must not be blank"))
|
||||
errs = append(errs, ErrInvalidGitPass)
|
||||
}
|
||||
|
||||
if c.GitBranch == "" {
|
||||
errs = append(errs, errors.New("invalid branch name for git, must not be blank"))
|
||||
errs = append(errs, ErrInvalidBranchName)
|
||||
}
|
||||
|
||||
return errs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue