Skip to content

Commit

Permalink
feat: use uint32 for page count (#193)
Browse files Browse the repository at this point in the history
* feat: test build in circleci
* fix: use uint32 for page count
  • Loading branch information
kindermoumoute authored Sep 26, 2019
1 parent 5cf7cef commit 1a5dc47
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 122 deletions.
58 changes: 44 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,27 @@
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
test-go-1-13:
test-go-tip: &base-test
docker:
- image: circleci/golang:1.13
- image: circleci/golang:latest
steps:
- checkout
- run: go mod download
- run:
name: Run unit tests
command: go test -v ./...
test-go-1-13:
<<: *base-test
docker:
- image: circleci/golang:1.13
test-go-1-12:
<<: *base-test
docker:
- image: circleci/golang:1.12
steps:
- checkout
- run: go mod download
- run:
name: Run unit tests
command: go test -v ./...
test-go-1-11:
<<: *base-test
docker:
- image: circleci/golang:1.11
steps:
- checkout
- run: go mod download
- run:
name: Run unit tests
command: go test -v ./...
test-go-1-10:
docker:
- image: circleci/golang:1.10
Expand All @@ -40,11 +34,47 @@ jobs:
- run:
name: Run unit tests
command: go test -v ./...

test-build-1-13-amd64: &base-build
docker:
- image: circleci/golang:1.13
environment:
GOARCH: amd64
steps:
- checkout
- run: go mod download
- run:
name: Test build
command: go build ./...
test-build-1-13-arm:
<<: *base-build
docker:
- image: circleci/golang:1.13
environment:
GOARCH: arm
test-build-1-13-arm64:
<<: *base-build
docker:
- image: circleci/golang:1.13
environment:
GOARCH: arm64
test-build-1-13-386:
<<: *base-build
docker:
- image: circleci/golang:1.13
environment:
GOARCH: 386

workflows:
version: 2
test:
jobs:
- test-go-tip
- test-go-1-13
- test-go-1-12
- test-go-1-11
- test-go-1-10
- test-build-1-13-amd64
- test-build-1-13-arm
- test-build-1-13-arm64
- test-build-1-13-386
8 changes: 4 additions & 4 deletions api/account/v2alpha1/account_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ func (s *API) ListSSHKeys(req *ListSSHKeysRequest, opts ...scw.RequestOption) (*

// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListSSHKeysResponse) UnsafeGetTotalCount() int {
return int(r.TotalCount)
func (r *ListSSHKeysResponse) UnsafeGetTotalCount() uint32 {
return r.TotalCount
}

// UnsafeAppend should not be used
// Internal usage only
func (r *ListSSHKeysResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) {
func (r *ListSSHKeysResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) {
results, ok := res.(*ListSSHKeysResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}

r.SSHKeys = append(r.SSHKeys, results.SSHKeys...)
r.TotalCount += uint32(len(results.SSHKeys))
return len(results.SSHKeys), nil
return uint32(len(results.SSHKeys)), nil
}

type CreateSSHKeyRequest struct {
Expand Down
16 changes: 8 additions & 8 deletions api/baremetal/v1alpha1/baremetal_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,21 +491,21 @@ func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*

// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListServersResponse) UnsafeGetTotalCount() int {
return int(r.TotalCount)
func (r *ListServersResponse) UnsafeGetTotalCount() uint32 {
return r.TotalCount
}

// UnsafeAppend should not be used
// Internal usage only
func (r *ListServersResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) {
func (r *ListServersResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) {
results, ok := res.(*ListServersResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}

r.Servers = append(r.Servers, results.Servers...)
r.TotalCount += uint32(len(results.Servers))
return len(results.Servers), nil
return uint32(len(results.Servers)), nil
}

type GetServerRequest struct {
Expand Down Expand Up @@ -934,21 +934,21 @@ func (s *API) ListServerEvents(req *ListServerEventsRequest, opts ...scw.Request

// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListServerEventsResponse) UnsafeGetTotalCount() int {
return int(r.TotalCount)
func (r *ListServerEventsResponse) UnsafeGetTotalCount() uint32 {
return r.TotalCount
}

// UnsafeAppend should not be used
// Internal usage only
func (r *ListServerEventsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) {
func (r *ListServerEventsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) {
results, ok := res.(*ListServerEventsResponse)
if !ok {
return 0, errors.New("%T type cannot be appended to type %T", res, r)
}

r.Event = append(r.Event, results.Event...)
r.TotalCount += uint32(len(results.Event))
return len(results.Event), nil
return uint32(len(results.Event)), nil
}

type CreateRemoteServerAccessRequest struct {
Expand Down
Loading

0 comments on commit 1a5dc47

Please sign in to comment.