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 }} 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 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()) +}