Skip to content

Commit 306cdae

Browse files
Fix cursor executionTime statistics getter (#386)
* Fix cursor executionTime statistics getter * Update CHANGELOG
1 parent 50ae839 commit 306cdae

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [master](https://github.com/arangodb/go-driver/tree/master) (N/A)
44
- Add support for `exclusive` field for transaction options
5+
- Fix cursor executionTime statistics getter
56

67
## [1.3.0](https://github.com/arangodb/go-driver/tree/v1.3.0) (2022-03-17)
78
- Disallow unknown fields feature

cursor_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,5 +319,5 @@ func (cs cursorStats) FullCount() int64 {
319319

320320
// query execution time (wall-clock time). value will be set from the outside
321321
func (cs cursorStats) ExecutionTime() time.Duration {
322-
return time.Duration(cs.ExecutionTimeInt) * time.Second
322+
return time.Duration(cs.ExecutionTimeInt * float64(time.Second))
323323
}

test/cursor_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ import (
2828
"testing"
2929
"time"
3030

31-
driver "github.com/arangodb/go-driver"
3231
"github.com/stretchr/testify/require"
32+
33+
driver "github.com/arangodb/go-driver"
3334
)
3435

3536
func TestCreateCursorWithMaxRuntime(t *testing.T) {
@@ -288,6 +289,10 @@ func TestCreateCursor(t *testing.T) {
288289
}
289290
}
290291
}
292+
293+
executionTime := cursor.Statistics().ExecutionTime()
294+
require.Greaterf(t, executionTime.Nanoseconds(), int64(0), "execution time must be greater than 0")
295+
291296
// Close anyway (this tests calling Close more than once)
292297
if err := cursor.Close(); err != nil {
293298
t.Errorf("Expected success in Close of cursor from query %d (%s), got '%s'", i, test.Query, describe(err))

0 commit comments

Comments
 (0)