mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
Revert "dialect: add alwaysfail driver (#1053)"
This reverts commit b3e118d301.
This commit is contained in:
@@ -140,25 +140,3 @@ func (d *DebugTx) Rollback() error {
|
||||
d.log(d.ctx, fmt.Sprintf("Tx(%s): rollbacked", d.id))
|
||||
return d.Tx.Rollback()
|
||||
}
|
||||
|
||||
type errDriver struct {
|
||||
Driver
|
||||
err error
|
||||
}
|
||||
|
||||
func (d errDriver) Exec(context.Context, string, interface{}, interface{}) error {
|
||||
return d.err
|
||||
}
|
||||
|
||||
func (d errDriver) Query(context.Context, string, interface{}, interface{}) error {
|
||||
return d.err
|
||||
}
|
||||
|
||||
func (d errDriver) Tx(context.Context) (Tx, error) {
|
||||
return nil, d.err
|
||||
}
|
||||
|
||||
// AlwaysFail returns a driver that always returns the given error.
|
||||
func AlwaysFail(driver Driver, err error) Driver {
|
||||
return errDriver{driver, err}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright 2019-present Facebook Inc. All rights reserved.
|
||||
// This source code is licensed under the Apache 2.0 license found
|
||||
// in the LICENSE file in the root directory of this source tree.
|
||||
|
||||
package dialect_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/facebook/ent/dialect"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type driver struct {
|
||||
dialect.Driver
|
||||
}
|
||||
|
||||
func (driver) Dialect() string { return "driver" }
|
||||
|
||||
func TestAlwaysFail(t *testing.T) {
|
||||
d := driver{}
|
||||
fd := dialect.AlwaysFail(d, fmt.Errorf("error"))
|
||||
_, err := fd.Tx(context.Background())
|
||||
require.Error(t, err)
|
||||
require.EqualError(t, err, "error")
|
||||
require.Equal(t, d.Dialect(), fd.Dialect())
|
||||
}
|
||||
Reference in New Issue
Block a user