Skip to content

Commit

Permalink
Merge pull request #7227 from hs0210/work
Browse files Browse the repository at this point in the history
Add unit test case to improve test coverage for go/sqltypes/result.go
  • Loading branch information
sougou authored Dec 29, 2020
2 parents 26de764 + b4dff7d commit 1300808
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions go/sqltypes/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,53 @@ func TestStripMetaData(t *testing.T) {
}
}
}

func TestAppendResult(t *testing.T) {
src := &Result{
Fields: []*querypb.Field{{
Type: Int64,
}, {
Type: VarChar,
}},
InsertID: 1,
RowsAffected: 2,
Rows: [][]Value{
{TestValue(Int64, "2"), MakeTrusted(VarChar, nil)},
{TestValue(Int64, "3"), TestValue(VarChar, "")},
},
}

result := &Result{
Fields: []*querypb.Field{{
Type: Int64,
}, {
Type: VarChar,
}},
InsertID: 3,
RowsAffected: 4,
Rows: [][]Value{
{TestValue(Int64, "1"), MakeTrusted(Null, nil)},
},
}

want := &Result{
Fields: []*querypb.Field{{
Type: Int64,
}, {
Type: VarChar,
}},
InsertID: 1,
RowsAffected: 6,
Rows: [][]Value{
{TestValue(Int64, "1"), MakeTrusted(Null, nil)},
{TestValue(Int64, "2"), MakeTrusted(VarChar, nil)},
{TestValue(Int64, "3"), TestValue(VarChar, "")},
},
}

result.AppendResult(src)

if !reflect.DeepEqual(result, want) {
t.Errorf("Got:\n%#v, want:\n%#v", result, want)
}
}

0 comments on commit 1300808

Please sign in to comment.