1
0
mirror of https://github.com/zhashkevych/go-sqlxmock.git synced 2024-11-16 17:41:57 +02:00

added tests

This commit is contained in:
Nikita Koryabkin 2019-12-04 09:02:10 +03:00
parent 5dc976bc43
commit 594a047e2f
2 changed files with 34 additions and 0 deletions

View File

@ -99,3 +99,20 @@ func TestQueryExpectationArgComparisonBool(t *testing.T) {
t.Error("arguments should not match, since argument is different")
}
}
type panicConverter struct {
}
func (s panicConverter) ConvertValue(v interface{}) (driver.Value, error) {
panic(v)
}
func Test_queryBasedExpectation_attemptArgMatch(t *testing.T) {
e := &queryBasedExpectation{converter: new(panicConverter), args: []driver.Value{"test"}}
values := []namedValue{
{Ordinal: 1, Name: "test", Value: "test"},
}
if err := e.attemptArgMatch(values); err == nil {
t.Errorf("error expected")
}
}

View File

@ -155,3 +155,20 @@ func TestQueryExpectationNamedArgComparison(t *testing.T) {
t.Errorf("arguments should have matched, but it did not: %v", err)
}
}
type panicConverter struct {
}
func (s panicConverter) ConvertValue(v interface{}) (driver.Value, error) {
panic(v)
}
func Test_queryBasedExpectation_attemptArgMatch(t *testing.T) {
e := &queryBasedExpectation{converter: new(panicConverter), args: []driver.Value{"test"}}
values := []driver.NamedValue{
{Ordinal: 1, Name: "test", Value: "test"},
}
if err := e.attemptArgMatch(values); err == nil {
t.Errorf("error expected")
}
}