Revert "dialect: add alwaysfail driver (#1053)"

This reverts commit b3e118d301.
This commit is contained in:
Ariel Mashraki
2020-12-17 15:59:49 +02:00
parent b3e118d301
commit 70fbcb24e5
2 changed files with 0 additions and 52 deletions

View File

@@ -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}
}

View File

@@ -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())
}