Exemplo n.º 1
0
func (matcher *HaveKeyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	switch matcher.Key.(type) {
	case omegaMatcher:
		return format.Message(actual, "not to have key matching", matcher.Key)
	default:
		return format.Message(actual, "not to have key", matcher.Key)
	}
}
func (matcher *HaveKeyWithValueMatcher) FailureMessage(actual interface{}) (message string) {
	str := "to have {key: value}"
	if _, ok := matcher.Key.(omegaMatcher); ok {
		str += " matching"
	} else if _, ok := matcher.Value.(omegaMatcher); ok {
		str += " matching"
	}

	expect := make(map[interface{}]interface{}, 1)
	expect[matcher.Key] = matcher.Value
	return format.Message(actual, str, expect)
}
func (matcher *HaveKeyWithValueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	kStr := "not to have key"
	if _, ok := matcher.Key.(omegaMatcher); ok {
		kStr = "not to have key matching"
	}

	vStr := "or that key's value not be"
	if _, ok := matcher.Value.(omegaMatcher); ok {
		vStr = "or to have that key's value not matching"
	}

	return format.Message(actual, kStr, matcher.Key, vStr, matcher.Value)
}
Exemplo n.º 4
0
func (matcher *ReceiveMatcher) FailureMessage(actual interface{}) (message string) {
	subMatcher, hasSubMatcher := (matcher.Arg).(omegaMatcher)

	closedAddendum := ""
	if matcher.channelClosed {
		closedAddendum = " The channel is closed."
	}

	if hasSubMatcher {
		if matcher.receivedValue.IsValid() {
			return subMatcher.FailureMessage(matcher.receivedValue.Interface())
		}
		return "When passed a matcher, ReceiveMatcher's channel *must* receive something."
	} else {
		return format.Message(actual, "to receive something."+closedAddendum)
	}
}
Exemplo n.º 5
0
func (matcher *BeARegularFileMatcher) FailureMessage(actual interface{}) (message string) {
	return format.Message(actual, fmt.Sprintf("to be a regular file: %s", matcher.err))
}
Exemplo n.º 6
0
func (matcher *PanicMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to panic")
}
Exemplo n.º 7
0
func (matcher *HaveSuffixMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to have suffix", matcher.suffix())
}
Exemplo n.º 8
0
func (matcher *BeClosedMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "to be open")
}
Exemplo n.º 9
0
func (matcher *BeADirectoryMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, fmt.Sprintf("not be a directory"))
}
Exemplo n.º 10
0
func (matcher *BeADirectoryMatcher) FailureMessage(actual interface{}) (message string) {
	return format.Message(actual, fmt.Sprintf("to be a directory: %s", matcher.err))
}
Exemplo n.º 11
0
func (matcher *ContainSubstringMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to contain substring", matcher.stringToMatch())
}
Exemplo n.º 12
0
func (matcher *BeNumericallyMatcher) FailureMessage(actual interface{}) (message string) {
	return format.Message(actual, fmt.Sprintf("to be %s", matcher.Comparator), matcher.CompareTo[0])
}
func (matcher *AssignableToTypeOfMatcher) NegatedFailureMessage(actual interface{}) string {
	return format.Message(actual, fmt.Sprintf("not to be assignable to the type: %T", matcher.Expected))
}
Exemplo n.º 14
0
func (matcher *BeAnExistingFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, fmt.Sprintf("not to exist"))
}
Exemplo n.º 15
0
func (matcher *BeARegularFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, fmt.Sprintf("not be a regular file"))
}
Exemplo n.º 16
0
func (matcher *MatchErrorMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to match error", matcher.Expected)
}
Exemplo n.º 17
0
func (matcher *BeEmptyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to be empty")
}
Exemplo n.º 18
0
func (matcher *BeNilMatcher) FailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "to be nil")
}
Exemplo n.º 19
0
func (matcher *BeSentMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to send:", matcher.Arg)
}
Exemplo n.º 20
0
func (matcher *EqualMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to equal", matcher.Expected)
}
Exemplo n.º 21
0
func (matcher *BeClosedMatcher) FailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "to be closed")
}
Exemplo n.º 22
0
func (matcher *HavePrefixMatcher) FailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "to have prefix", matcher.prefix())
}
Exemplo n.º 23
0
func (matcher *BeEquivalentToMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to be equivalent to", matcher.Expected)
}
Exemplo n.º 24
0
func (matcher *BeTemporallyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, fmt.Sprintf("not to be %s", matcher.Comparator), matcher.CompareTo)
}
Exemplo n.º 25
0
func (matcher *BeZeroMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to be zero-valued")
}
Exemplo n.º 26
0
func (matcher *ConsistOfMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to consist of", matcher.Elements)
}
Exemplo n.º 27
0
func (matcher *MatchJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	actualString, expectedString, _ := matcher.prettyPrint(actual)
	return format.Message(actualString, "not to match JSON of", expectedString)
}
Exemplo n.º 28
0
func (matcher *ContainElementMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to contain element matching", matcher.Element)
}
Exemplo n.º 29
0
func (matcher *BeTrueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to be true")
}
Exemplo n.º 30
0
func (matcher *BeFalseMatcher) FailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "to be false")
}