| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- // Copyright 2017 The Xorm Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style
- // license that can be found in the LICENSE file.
- package xorm
- import (
- "testing"
- "github.com/stretchr/testify/assert"
- )
- func TestRows(t *testing.T) {
- assert.NoError(t, prepareEngine())
- type UserRows struct {
- Id int64
- IsMan bool
- }
- assert.NoError(t, testEngine.Sync2(new(UserRows)))
- cnt, err := testEngine.Insert(&UserRows{
- IsMan: true,
- })
- assert.NoError(t, err)
- assert.EqualValues(t, 1, cnt)
- rows, err := testEngine.Rows(new(UserRows))
- assert.NoError(t, err)
- defer rows.Close()
- cnt = 0
- user := new(UserRows)
- for rows.Next() {
- err = rows.Scan(user)
- assert.NoError(t, err)
- cnt++
- }
- assert.EqualValues(t, 1, cnt)
- }
|