From 7823ff1e2625cfbe7316e1eba75b2fdb7e43c8e2 Mon Sep 17 00:00:00 2001 From: Mojtaba Arezoomand Date: Sat, 3 Feb 2024 13:54:13 +0330 Subject: [PATCH 1/3] chore: bump go version --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2a11642..5ef2a59 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mojixcoder/gosrm -go 1.20 +go 1.21 require github.com/stretchr/testify v1.8.2 From 839cad2057854f9a77369f5521e25f94bb378fa8 Mon Sep 17 00:00:00 2001 From: Mojtaba Arezoomand Date: Sat, 3 Feb 2024 13:55:20 +0330 Subject: [PATCH 2/3] ci: added go1.21 to the test pipeline --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 376ba72..702bbdc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ on: env: # Upload coverage only for this go version. - LATEST_GO_VERSION: "1.20" + LATEST_GO_VERSION: "1.21" jobs: test: @@ -23,7 +23,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - go: ["1.18", "1.19", "1.20"] + go: ["1.18", "1.19", "1.20", "1.21"] name: ${{ matrix.os }} & Go ${{ matrix.go }} From 4e376943a79cedbdfb75f9393ab87199274e026c Mon Sep 17 00:00:00 2001 From: Mojtaba Arezoomand Date: Sat, 3 Feb 2024 14:03:58 +0330 Subject: [PATCH 3/3] feat: added is ok method for OSRM responses --- types.go | 5 +++++ types_test.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 types_test.go diff --git a/types.go b/types.go index e1a3b9f..693c262 100644 --- a/types.go +++ b/types.go @@ -287,3 +287,8 @@ type ( Confidence float32 `json:"confidence"` } ) + +// IsOk returns true if request could be processed as expected by OSRM. +func (res Response) IsOk() bool { + return res.Code == CodeOK +} diff --git a/types_test.go b/types_test.go new file mode 100644 index 0000000..33b82eb --- /dev/null +++ b/types_test.go @@ -0,0 +1,15 @@ +package gosrm + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestResponse_IsOk(t *testing.T) { + res := Response{Code: CodeOK} + assert.True(t, res.IsOk()) + + res.Code = CodeInvalidQuery + assert.False(t, res.IsOk()) +}