mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Support matchers on integers in integration tests
This commit is contained in:
58
pkg/integration/components/int_matcher.go
Normal file
58
pkg/integration/components/int_matcher.go
Normal file
@ -0,0 +1,58 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type IntMatcher struct {
|
||||
*Matcher[int]
|
||||
}
|
||||
|
||||
func (self *IntMatcher) EqualsInt(target int) *IntMatcher {
|
||||
self.appendRule(matcherRule[int]{
|
||||
name: fmt.Sprintf("equals '%d'", target),
|
||||
testFn: func(value int) (bool, string) {
|
||||
return value == target, fmt.Sprintf("Expected '%d' to equal '%d'", value, target)
|
||||
},
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *IntMatcher) GreaterThan(target int) *IntMatcher {
|
||||
self.appendRule(matcherRule[int]{
|
||||
name: fmt.Sprintf("greater than '%d'", target),
|
||||
testFn: func(value int) (bool, string) {
|
||||
return value > target, fmt.Sprintf("Expected '%d' to greater than '%d'", value, target)
|
||||
},
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *IntMatcher) LessThan(target int) *IntMatcher {
|
||||
self.appendRule(matcherRule[int]{
|
||||
name: fmt.Sprintf("less than '%d'", target),
|
||||
testFn: func(value int) (bool, string) {
|
||||
return value < target, fmt.Sprintf("Expected '%d' to less than '%d'", value, target)
|
||||
},
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func AnyInt() *IntMatcher {
|
||||
return &IntMatcher{Matcher: &Matcher[int]{}}
|
||||
}
|
||||
|
||||
func EqualsInt(target int) *IntMatcher {
|
||||
return AnyInt().EqualsInt(target)
|
||||
}
|
||||
|
||||
func GreaterThan(target int) *IntMatcher {
|
||||
return AnyInt().GreaterThan(target)
|
||||
}
|
||||
|
||||
func LessThan(target int) *IntMatcher {
|
||||
return AnyInt().LessThan(target)
|
||||
}
|
Reference in New Issue
Block a user