Skip to content

Commit

Permalink
Fix golint
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaeumer committed Mar 17, 2019
1 parent f919945 commit 85b8f73
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewCommand(cmd string) *Command {
}
}

//SetTimeoutMS sets the timeout in milliseconds
func (c *Command) SetTimeoutMS(ms int) {
if ms == 0 {
c.Timeout = 1 * time.Minute
Expand Down Expand Up @@ -102,7 +103,7 @@ func (c *Command) Execute() error {
case <-time.After(c.Timeout):
log.Println("Command timed out", c.Cmd)
if err := cmd.Process.Kill(); err != nil {
return fmt.Errorf("Timeout occured and can not kill process with pid %v", cmd.Process.Pid)
return fmt.Errorf("Timeout occurred and can not kill process with pid %v", cmd.Process.Pid)
}
return fmt.Errorf("Command timed out after %v", c.Timeout)
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/matcher/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import (
)

const (
// Text matcher type
Text = "text"
// Contains matcher type
Contains = "contains"
// Equal matcher type
Equal = "equal"
)

// NewMatcher creates a new matcher by type
func NewMatcher(matcher string) Matcher {
switch matcher {
case Text:
Expand All @@ -25,18 +29,22 @@ func NewMatcher(matcher string) Matcher {
}
}

// Matcher interface which is implemented by all matchers
type Matcher interface {
Match(actual interface{}, expected interface{}) MatcherResult
}

// MatcherResult will be returned by the executed matcher
type MatcherResult struct {
Success bool
Diff string
}

// TextMatcher matches if two texts are equals
type TextMatcher struct {
}

// Match matches both texts
func (m TextMatcher) Match(got interface{}, expected interface{}) MatcherResult {
result := true
if got != expected {
Expand All @@ -58,9 +66,11 @@ func (m TextMatcher) Match(got interface{}, expected interface{}) MatcherResult
}
}

// ContainsMatcher tests if the expected value is in the got variable
type ContainsMatcher struct {
}

// Match matches on the given values
func (m ContainsMatcher) Match(got interface{}, expected interface{}) MatcherResult {
result := true
if !strings.Contains(got.(string), expected.(string)) {
Expand All @@ -82,9 +92,11 @@ func (m ContainsMatcher) Match(got interface{}, expected interface{}) MatcherRes
}
}

//EqualMatcher matches if given values are equal
type EqualMatcher struct {
}

//Match matches the values if they are equal
func (m EqualMatcher) Match(got interface{}, expected interface{}) MatcherResult {
if got == expected {
return MatcherResult{
Expand Down
1 change: 1 addition & 0 deletions pkg/suite/yaml_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type YAMLConfig struct {
Config YAMLTestConfig `yaml:"config"`
}

// YAMLTestConfig is a struct to represent the test config
type YAMLTestConfig struct {
Env []string `yaml:"env"`
Dir string `yaml:"dir"`
Expand Down

0 comments on commit 85b8f73

Please sign in to comment.