Skip to content

Commit 662c7e5

Browse files
authored
feat: added is ok method for OSRM responses (#4)
* 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]>
1 parent 426a192 commit 662c7e5

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

.github/workflows/test.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
env:
1212
# Upload coverage only for this go version.
13-
LATEST_GO_VERSION: "1.20"
13+
LATEST_GO_VERSION: "1.21"
1414

1515
jobs:
1616
test:
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
matrix:
2525
os: ["ubuntu-latest"]
26-
go: ["1.18", "1.19", "1.20"]
26+
go: ["1.18", "1.19", "1.20", "1.21"]
2727

2828
name: ${{ matrix.os }} & Go ${{ matrix.go }}
2929

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/mojixcoder/gosrm
22

3-
go 1.20
3+
go 1.21
44

55
require github.com/stretchr/testify v1.8.2
66

types.go

+5
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,8 @@ type (
287287
Confidence float32 `json:"confidence"`
288288
}
289289
)
290+
291+
// IsOk returns true if request could be processed as expected by OSRM.
292+
func (res Response) IsOk() bool {
293+
return res.Code == CodeOK
294+
}

types_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package gosrm
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestResponse_IsOk(t *testing.T) {
10+
res := Response{Code: CodeOK}
11+
assert.True(t, res.IsOk())
12+
13+
res.Code = CodeInvalidQuery
14+
assert.False(t, res.IsOk())
15+
}

0 commit comments

Comments
 (0)