Skip to content

Commit

Permalink
feat: added is ok method for OSRM responses (#4)
Browse files Browse the repository at this point in the history
* chore: bump go version

* ci: added go1.21 to the test pipeline

* feat: added is ok method for OSRM responses

---------

Co-authored-by: Mojtaba Arezoomand <[email protected]>
  • Loading branch information
mojixcoder and mojixcoder authored Feb 3, 2024
1 parent 426a192 commit 662c7e5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mojixcoder/gosrm

go 1.20
go 1.21

require github.com/stretchr/testify v1.8.2

Expand Down
5 changes: 5 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
15 changes: 15 additions & 0 deletions types_test.go
Original file line number Diff line number Diff line change
@@ -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())
}

0 comments on commit 662c7e5

Please sign in to comment.