xorm/executor/executor_test.go

36 lines
699 B
Go
Raw Normal View History

2023-10-28 03:58:27 +00:00
// Copyright 2023 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.
2023-10-28 09:45:30 +00:00
package executor
2023-10-28 03:58:27 +00:00
import (
"context"
"testing"
"xorm.io/xorm/v2"
_ "github.com/mattn/go-sqlite3"
"github.com/stretchr/testify/assert"
)
2023-10-28 09:45:30 +00:00
func TestExecutor(t *testing.T) {
2023-10-28 03:58:27 +00:00
type User struct {
Id int64
Name string
}
engine, err := xorm.NewEngine("sqlite3", "file::memory:?cache=shared")
assert.NoError(t, err)
assert.NoError(t, engine.Sync(new(User)))
// create querier
2023-10-28 09:45:30 +00:00
querier := New[User](engine)
2023-10-28 03:58:27 +00:00
users, err := querier.All(context.Background())
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(users), 0)
}