Skip to content

Commit

Permalink
Merge pull request #38 from maier/master
Browse files Browse the repository at this point in the history
v0.7.18 [CIRC-8950]
  • Loading branch information
maier authored Aug 17, 2022
2 parents 36ced95 + 5c1bbaa commit b35b574
Show file tree
Hide file tree
Showing 30 changed files with 2,136 additions and 641 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
tags: [ "v*" ]
branches: [ master ]
pull_request:
branches: [ "*" ]

jobs:
golangci:
name: lint
Expand All @@ -19,4 +19,6 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
args: --timeout=5m
version: v1.48
skip-go-installation: true
args: --timeout=5m
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# v0.7.18

* feat: clean tags - remove blanks and duplicates, lowercase, and sort
* fix: debug messages
* fix(lint): ioutil deprecation
* fix(lint): gofmt
* fix(lint): struct alignment
* chore: update to go1.17
* feat(deps): bump go-retryablehttp from 0.7.0 to 0.7.1
* chore: Merge remote-tracking branch 'upstream/master'

# v0.7.17

* upd: Implements a new DisableRetries configuration setting to allow the
Expand Down
79 changes: 61 additions & 18 deletions account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package apiclient
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -77,7 +77,7 @@ func testAccountServer() *httptest.Server {
fmt.Fprintln(w, string(ret))
case "PUT":
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -148,16 +148,32 @@ func TestFetchAccount(t *testing.T) {
apih, server := accountTestBootstrap(t)
defer server.Close()

tests := []struct { //nolint:govet
expectedType := "*apiclient.Account"
tests := []struct {
id string
cid string
expectedType string
shouldFail bool
expectedErr string
shouldFail bool
}{
{"valid (default,empty)", "", "*apiclient.Account", false, ""},
{"valid (short cid)", "1234", "*apiclient.Account", false, ""},
{"valid (long cid)", "/account/1234", "*apiclient.Account", false, ""},
{
id: "valid (default,empty)",
cid: "",
expectedType: expectedType,
shouldFail: false,
},
{
id: "valid (short cid)",
cid: "1234",
expectedType: expectedType,
shouldFail: false,
},
{
id: "valid (long cid)",
cid: "/account/1234",
expectedType: expectedType,
shouldFail: false,
},
}

for _, test := range tests {
Expand Down Expand Up @@ -201,16 +217,33 @@ func TestUpdateAccount(t *testing.T) {
apih, server := accountTestBootstrap(t)
defer server.Close()

tests := []struct { //nolint:govet
id string
tests := []struct {
cfg *Account
id string
expectedType string
shouldFail bool
expectedErr string
shouldFail bool
}{
{"invalid (nil)", nil, "", true, "invalid account config (nil)"},
{"invalid (cid)", &Account{CID: "/invalid"}, "", true, "invalid account CID (/invalid)"},
{"valid", &testAccount, "*apiclient.Account", false, ""},
{
id: "invalid (nil)",
cfg: nil,
expectedType: "",
shouldFail: true,
expectedErr: "invalid account config (nil)",
},
{
id: "invalid (cid)",
cfg: &Account{CID: "/invalid"},
expectedType: "",
shouldFail: true,
expectedErr: "invalid account CID (/invalid)",
},
{
id: "valid",
cfg: &testAccount,
expectedType: "*apiclient.Account",
shouldFail: false,
},
}

for _, test := range tests {
Expand Down Expand Up @@ -241,15 +274,25 @@ func TestSearchAccounts(t *testing.T) {
expectedType := "*[]apiclient.Account"
filter := SearchFilterType(map[string][]string{"f_name_wildcard": {"*ops*"}})

tests := []struct { //nolint:govet
id string
tests := []struct {
filter *SearchFilterType
id string
expectedType string
shouldFail bool
expectedErr string
shouldFail bool
}{
{"no filter", nil, expectedType, false, ""},
{"filter", &filter, expectedType, false, ""},
{
id: "no filter",
filter: nil,
expectedType: expectedType,
shouldFail: false,
},
{
id: "filter",
filter: &filter,
expectedType: expectedType,
shouldFail: false,
},
}

for _, test := range tests {
Expand Down
125 changes: 98 additions & 27 deletions acknowledgement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package apiclient
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -43,7 +43,7 @@ func testAcknowledgementServer() *httptest.Server {
fmt.Fprintln(w, string(ret))
case "PUT":
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -85,7 +85,7 @@ func testAcknowledgementServer() *httptest.Server {
}
case "POST":
defer r.Body.Close()
_, err := ioutil.ReadAll(r.Body)
_, err := io.ReadAll(r.Body)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -138,16 +138,32 @@ func TestFetchAcknowledgement(t *testing.T) {
apih, server := acknowledgementTestBootstrap(t)
defer server.Close()

tests := []struct { //nolint:govet
tests := []struct {
id string
cid string
expectedType string
shouldFail bool
expectedErr string
shouldFail bool
}{
{"invalid (empty cid)", "", "", true, "invalid acknowledgement CID (none)"},
{"valid (short cid)", "1234", "*apiclient.Acknowledgement", false, ""},
{"valid (long cid)", "/acknowledgement/1234", "*apiclient.Acknowledgement", false, ""},
{
id: "invalid (empty cid)",
cid: "",
expectedType: "",
shouldFail: true,
expectedErr: "invalid acknowledgement CID (none)",
},
{
id: "valid (short cid)",
cid: "1234",
expectedType: "*apiclient.Acknowledgement",
shouldFail: false,
},
{
id: "valid (long cid)",
cid: "/acknowledgement/1234",
expectedType: "*apiclient.Acknowledgement",
shouldFail: false,
},
}

for _, test := range tests {
Expand Down Expand Up @@ -189,15 +205,29 @@ func TestUpdateAcknowledgement(t *testing.T) {
apih, server := acknowledgementTestBootstrap(t)
defer server.Close()

tests := []struct { //nolint:govet
id string
tests := []struct {
cfg *Acknowledgement
shouldFail bool
id string
expectedErr string
shouldFail bool
}{
{"invalid (nil)", nil, true, "invalid acknowledgement config (nil)"},
{"invalid (cid)", &Acknowledgement{CID: "/invalid"}, true, "invalid acknowledgement CID (/invalid)"},
{"valid", &testAcknowledgement, false, ""},
{
id: "invalid (nil)",
cfg: nil,
shouldFail: true,
expectedErr: "invalid acknowledgement config (nil)",
},
{
id: "invalid (cid)",
cfg: &Acknowledgement{CID: "/invalid"},
shouldFail: true,
expectedErr: "invalid acknowledgement CID (/invalid)",
},
{
id: "valid",
cfg: &testAcknowledgement,
shouldFail: false,
},
}

for _, test := range tests {
Expand All @@ -223,16 +253,33 @@ func TestCreateAcknowledgement(t *testing.T) {
apih, server := acknowledgementTestBootstrap(t)
defer server.Close()

tests := []struct { //nolint:govet
id string
tests := []struct {
cfg *Acknowledgement
id string
expectedType string
shouldFail bool
expectedErr string
shouldFail bool
}{
{"invalid (nil)", nil, "", true, "invalid acknowledgement config (nil)"},
{"invalid (cid)", &Acknowledgement{CID: "/invalid"}, "", true, "invalid acknowledgement CID (/invalid)"},
{"valid", &testAcknowledgement, "*apiclient.Acknowledgement", false, ""},
{
id: "invalid (nil)",
cfg: nil,
expectedType: "",
shouldFail: true,
expectedErr: "invalid acknowledgement config (nil)",
},
{
id: "invalid (cid)",
cfg: &Acknowledgement{CID: "/invalid"},
expectedType: "",
shouldFail: true,
expectedErr: "invalid acknowledgement CID (/invalid)",
},
{
id: "valid",
cfg: &testAcknowledgement,
expectedType: "*apiclient.Acknowledgement",
shouldFail: false,
},
}

for _, test := range tests {
Expand Down Expand Up @@ -264,18 +311,42 @@ func TestSearchAcknowledgement(t *testing.T) {
search := SearchQueryType(`(notes="something")`)
filter := SearchFilterType(map[string][]string{"f__active": {"true"}})

tests := []struct { //nolint:govet
id string
tests := []struct {
search *SearchQueryType
filter *SearchFilterType
id string
expectedType string
shouldFail bool
expectedErr string
shouldFail bool
}{
{"no search, no filter", nil, nil, expectedType, false, ""},
{"search no filter", &search, nil, expectedType, false, ""},
{"filter no search", nil, &filter, expectedType, false, ""},
{"both filter and search", &search, &filter, expectedType, false, ""},
{
id: "no search, no filter",
search: nil,
filter: nil,
expectedType: expectedType,
shouldFail: false,
},
{
id: "search no filter",
search: &search,
filter: nil,
expectedType: expectedType,
shouldFail: false,
},
{
id: "filter no search",
search: nil,
filter: &filter,
expectedType: expectedType,
shouldFail: false,
},
{
id: "both filter and search",
search: &search,
filter: &filter,
expectedType: expectedType,
shouldFail: false,
},
}

for _, test := range tests {
Expand Down
Loading

0 comments on commit b35b574

Please sign in to comment.