Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added is ok method for OSRM responses #4

Merged
merged 3 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
}
Loading