Merge pull request #57 from nspcc-dev/fix-bug-with-object-request-interface

[NPE] Fix bug with object request interface
This commit is contained in:
Evgeniy Kulikov 2020-03-16 18:55:58 +03:00 committed by GitHub
commit e353463bfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 4 deletions

View file

@ -1,5 +1,17 @@
name: Go
on: [push]
on:
push:
branches:
- master
- develop
paths-ignore:
- '*.md'
pull_request:
branches:
- master
- develop
paths-ignore:
- '*.md'
jobs:
test:
@ -7,16 +19,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.11.x', '1.12.x', '1.13.x']
go: [ '1.12.x', '1.13.x', '1.14.x']
steps:
- name: Setup go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Set GOPATH
# temporary fix
@ -26,6 +39,13 @@ jobs:
echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin"
shell: bash
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: |
go get -u -v golang.org/x/lint/golint

View file

@ -124,7 +124,12 @@ func (m *GetResponse) NotFull() bool { return checkIsNotFull(m) }
func (m *PutRequest) NotFull() bool { return checkIsNotFull(m) }
// CID returns container id value from object put request.
func (m *PutRequest) CID() CID { return m.GetHeader().Object.SystemHeader.CID }
func (m *PutRequest) CID() CID {
if header := m.GetHeader(); header != nil {
return header.Object.SystemHeader.CID
}
return refs.CID{}
}
// CID returns container id value from object get request.
func (m *GetRequest) CID() CID { return m.Address.CID }

28
object/service_test.go Normal file
View file

@ -0,0 +1,28 @@
package object
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestRequest(t *testing.T) {
cases := []Request{
&PutRequest{},
&GetRequest{},
&HeadRequest{},
&SearchRequest{},
&DeleteRequest{},
&GetRangeRequest{},
&GetRangeHashRequest{},
}
for i := range cases {
v := cases[i]
t.Run(fmt.Sprintf("%T", v), func(t *testing.T) {
require.NotPanics(t, func() { v.CID() })
})
}
}