Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle https://xorm.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
606B

  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build go1.8
  5. package xorm
  6. import (
  7. "context"
  8. "testing"
  9. "time"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestPingContext(t *testing.T) {
  13. assert.NoError(t, prepareEngine())
  14. ctx, canceled := context.WithTimeout(context.Background(), time.Nanosecond)
  15. defer canceled()
  16. time.Sleep(time.Nanosecond)
  17. err := testEngine.(*Engine).PingContext(ctx)
  18. assert.Error(t, err)
  19. assert.Contains(t, err.Error(), "context deadline exceeded")
  20. }