Skip to content

Commit

Permalink
Enhance the codebase (#349)
Browse files Browse the repository at this point in the history
* Add Go 1.23 for testing

* fix warning

* change docker-compose to docker compose

change SessionPool's List as List ref

remove unused tz field in the SessionPool

Revert "change SessionPool's List as List ref"

This reverts commit 890329f.

debug

* Revert "change docker-compose to docker compose"

This reverts commit c37c273.

* fix deprecated method
  • Loading branch information
haoxins authored Sep 14, 2024
1 parent 51cefe1 commit 4e4de32
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
goVer: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22']
goVer: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@v2
- name: Setup go ${{ matrix.goVer }}
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
goVer: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22']
goVer: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@v2
- name: Setup go ${{ matrix.goVer }}
Expand All @@ -67,7 +67,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
goVer: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22']
goVer: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@v2
- name: Setup go ${{ matrix.goVer }}
Expand Down
4 changes: 2 additions & 2 deletions configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -108,7 +108,7 @@ func openAndReadFile(path string) ([]byte, error) {
return nil, fmt.Errorf("unable to open file %s: %s", path, err)
}
// read file
b, err := ioutil.ReadAll(f)
b, err := io.ReadAll(f)
if err != nil {
return nil, fmt.Errorf("unable to ReadAll file %s: %s", path, err)
}
Expand Down
3 changes: 2 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ func (cn *connection) ExecuteJsonWithParameter(sessionID int64, stmt string, par
jsonResp, err := cn.graph.ExecuteJsonWithParameter(sessionID, []byte(stmt), params)
if err != nil {
// reopen the connection if timeout
if _, ok := err.(thrift.TransportException); ok {
_, ok := err.(thrift.TransportException)
if ok {
if err.(thrift.TransportException).TypeID() == thrift.TIMED_OUT {
reopenErr := cn.reopen()
if reopenErr != nil {
Expand Down
24 changes: 12 additions & 12 deletions result_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ func TestNode(t *testing.T) {
vertex := getVertex("Tom", 3, 5)
node, err := genNode(vertex, testTimezone)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

assert.Equal(t, "\"Tom\"", node.GetID().String())
Expand All @@ -517,7 +517,7 @@ func TestNode(t *testing.T) {
for i := 0; i < len(keysCopy); i++ {
actualVal, err := props[keysCopy[i]].AsInt()
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
assert.Equal(t, int64(i), actualVal)
}
Expand All @@ -527,7 +527,7 @@ func TestRelationship(t *testing.T) {
edge := getEdge("Tom", "Lily", 5)
relationship, err := genRelationship(edge, testTimezone)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
assert.Equal(t, "\"Tom\"", relationship.GetSrcVertexID().String())
assert.Equal(t, "\"Lily\"", relationship.GetDstVertexID().String())
Expand All @@ -542,7 +542,7 @@ func TestRelationship(t *testing.T) {
for i := 0; i < len(keysCopy); i++ {
actualVal, err := props[keysCopy[i]].AsInt()
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
assert.Equal(t, int64(i), actualVal)
}
Expand All @@ -552,17 +552,17 @@ func TestPathWrapper(t *testing.T) {
path := getPath("Tom", 5)
pathWrapper, err := genPathWrapper(path, testTimezone)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
assert.Equal(t, 5, pathWrapper.GetPathLength())
node, err := genNode(getVertex("Tom", 3, 5), testTimezone)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
assert.Equal(t, true, pathWrapper.ContainsNode(*node))
relationship, err := genRelationship(getEdge("Tom", "vertex0", 5), testTimezone)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
assert.Equal(t, true, pathWrapper.ContainsRelationship(relationship))

Expand All @@ -571,7 +571,7 @@ func TestPathWrapper(t *testing.T) {
for i := 0; i < 5; i++ {
genNode, err := genNode(getVertex(fmt.Sprintf("vertex%d", i), 3, 5), testTimezone)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
nodeList = append(nodeList, *genNode)
}
Expand All @@ -587,7 +587,7 @@ func TestPathWrapper(t *testing.T) {
}
newRelationship, err := genRelationship(edge, testTimezone)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
relationshipList = append(relationshipList, newRelationship)
}
Expand Down Expand Up @@ -696,7 +696,7 @@ func TestResultSet(t *testing.T) {

record, err := resultSet.GetRowValuesByIndex(0)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
temp, _ := record.GetValueByIndex(0)
_, err = temp.AsNode()
Expand Down Expand Up @@ -839,7 +839,7 @@ func TestIntVid(t *testing.T) {
vertex := getVertexInt(101, 3, 5)
node, err := genNode(vertex, testTimezone)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

assert.Equal(t, "101", node.GetID().String())
Expand All @@ -854,7 +854,7 @@ func TestIntVid(t *testing.T) {
for i := 0; i < len(keysCopy); i++ {
actualVal, err := props[keysCopy[i]].AsInt()
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
assert.Equal(t, int64(i), actualVal)
}
Expand Down
1 change: 0 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ func (session *Session) ShowSpaces() ([]SpaceName, error) {
func (session *Session) reConnect() error {
newConnection, err := session.connPool.getIdleConn()
if err != nil {
err = fmt.Errorf(err.Error())
return err
}

Expand Down

0 comments on commit 4e4de32

Please sign in to comment.