xorm/engine_context_test.go
Lunny Xiao 5750e3f90a
Add context support (#1193)
* add context support

* improve pingcontext tests
2019-01-20 11:01:14 +08:00

27 lines
576 B
Go

// 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.
// +build go1.8
package xorm
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestPingContext(t *testing.T) {
assert.NoError(t, prepareEngine())
ctx, canceled := context.WithTimeout(context.Background(), time.Nanosecond)
defer canceled()
err := testEngine.(*Engine).PingContext(ctx)
assert.Error(t, err)
assert.Contains(t, err.Error(), "context deadline exceeded")
}