Skip to content

Commit

Permalink
fix various metalinter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
displague committed Aug 27, 2018
1 parent 1086496 commit e7e4839
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 138 deletions.
19 changes: 6 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@ go:
- "1.10"
- tip

before_install:
- go get github.com/mattn/goveralls
- go get github.com/lawrencewoodman/roveralls
- go get github.com/alecthomas/gometalinter

install:
- gometalinter --install

script:
- touch .env
- make vendor
- vendor/github.com/kubernetes/repo-infra/verify/verify-go-src.sh -v --rootdir $(pwd)
- make
- travis_wait 20 roveralls
# - goveralls -coverprofile=roveralls.coverprofile -service=travis-ci
- make test ARGS='-coverprofile=coverage.txt -covermode=atomic'"
- gometalinter.v2 --enable-all --disable=vetshadow --disable=gocyclo --disable=unparm --disable=nakedret --disable=lll --disable=dupl --disable=test --deadline=120s
- gometalinter.v2 --disable-all --enable=vetshadow --enable=gocyclo --enable=unparm --enable=nakedret --enable=lll --enable=dupl --enable=test --deadline=120s || true

after_success:
- bash <(curl -s https://codecov.io/bash)
39 changes: 15 additions & 24 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
# go-tests = true
# unused-packages = true

required = ["github.com/kubernetes/repo-infra/verify/boilerplate/test"]
ignored = ["github.com/kubernetes/repo-infra/kazel"]

[prune]
go-tests = true

[[constraint]]
branch = "master"
name = "github.com/kubernetes/repo-infra"
unused-packages = true
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ include .env
LINODE_FIXTURE_INSTANCE:=76859403
LINODE_FIXTURE_VOLUME:=6574839201

.PHONY: test
test: vendor
@LINODE_TEST_INSTANCE=$(LINODE_FIXTURE_INSTANCE) \
LINODE_TEST_VOLUME=$(LINODE_FIXTURE_VOLUME) \
LINODE_FIXTURE_MODE="play" \
LINODE_TOKEN="awesometokenawesometokenawesometoken" \
go test $(ARGS)

$(GOPATH)/bin/dep:
@go get -u github.com/golang/dep/cmd/dep

Expand Down Expand Up @@ -38,14 +46,6 @@ fixtures:
-e "s/$(LINODE_TEST_VOLUME)/$(LINODE_FIXTURE_VOLUME)/g" $$yaml; \
done

.PHONY: test
test: vendor
@LINODE_TEST_INSTANCE=$(LINODE_FIXTURE_INSTANCE) \
LINODE_TEST_VOLUME=$(LINODE_FIXTURE_VOLUME) \
LINODE_FIXTURE_MODE="play" \
LINODE_TOKEN="awesometokenawesometokenawesometoken" \
go test $(ARGS)

.PHONY: godoc
godoc:
@godoc -http=:6060
6 changes: 3 additions & 3 deletions domain_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ func (c *Client) CreateDomainRecord(ctx context.Context, domainID int, domainrec

req := c.R(ctx).SetResult(&DomainRecord{})

if bodyData, err := json.Marshal(domainrecord); err == nil {
body = string(bodyData)
} else {
bodyData, err := json.Marshal(domainrecord)
if err != nil {
return nil, NewError(err)
}
body = string(bodyData)

r, err := coupleAPIErrors(req.
SetBody(body).
Expand Down
21 changes: 19 additions & 2 deletions domain_records_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ func TestUpdateDomainRecord(t *testing.T) {
}
client, domain, record, teardown, err := setupDomainRecord(t, "fixtures/TestUpdateDomainRecord")
defer teardown()
if err != nil {
t.Error(err)
}

updateOpts := linodego.DomainRecordUpdateOptions{
Name: "renamed",
Expand All @@ -61,10 +64,16 @@ func TestListDomainRecords(t *testing.T) {
}
client, domain, record, teardown, err := setupDomainRecord(t, "fixtures/TestListDomainRecords")
defer teardown()
if err != nil {
t.Error(err)
}

filter, err := json.Marshal(map[string]interface{}{
"name": record.Name,
})
if err != nil {
t.Error(err)
}

listOpts := linodego.NewListOptions(0, string(filter))
records, err := client.ListDomainRecords(context.Background(), domain.ID, listOpts)
Expand All @@ -82,11 +91,16 @@ func TestListDomainRecordsMultiplePages(t *testing.T) {
}
client, domain, record, teardown, err := setupDomainRecord(t, "fixtures/TestListDomainRecordsMultiplePages")
defer teardown()
if err != nil {
t.Error(err)
}

filter, err := json.Marshal(map[string]interface{}{
"name": record.Name,
})

if err != nil {
t.Error(err)
}
listOpts := linodego.NewListOptions(0, string(filter))
records, err := client.ListDomainRecords(context.Background(), domain.ID, listOpts)
if err != nil {
Expand All @@ -103,6 +117,9 @@ func TestGetDomainRecord(t *testing.T) {
}
client, domain, record, teardown, err := setupDomainRecord(t, "fixtures/TestGetDomainRecord")
defer teardown()
if err != nil {
t.Error(err)
}

recordGot, err := client.GetDomainRecord(context.Background(), domain.ID, record.ID)
if recordGot.Name != record.Name {
Expand All @@ -128,7 +145,7 @@ func setupDomainRecord(t *testing.T, fixturesYaml string) (*linodego.Client, *li
}

teardown := func() {
// delete the DomainRecord to excercise the code
// delete the DomainRecord to exercise the code
if err := client.DeleteDomainRecord(context.Background(), domain.ID, record.ID); err != nil {
t.Errorf("Expected to delete a domain record, but got %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ func (c *Client) CreateDomain(ctx context.Context, domain DomainCreateOptions) (

req := c.R(ctx).SetResult(&Domain{})

if bodyData, err := json.Marshal(domain); err == nil {
body = string(bodyData)
} else {
bodyData, err := json.Marshal(domain)
if err != nil {
return nil, NewError(err)
}
body = string(bodyData)

r, err := coupleAPIErrors(req.
SetBody(body).
Expand Down
11 changes: 11 additions & 0 deletions domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ func TestUpdateDomain(t *testing.T) {
}
client, domain, teardown, err := setupDomain(t, "fixtures/TestUpdateDomain")
defer teardown()
if err != nil {
t.Error(err)
}

updateOpts := linodego.DomainUpdateOptions{
Domain: "linodego-renamed-domain.com",
}
domain, err = client.UpdateDomain(context.Background(), domain.ID, updateOpts)
if err != nil {
t.Errorf("Error renaming domain, %s", err)
} else if domain.Domain != updateOpts.Domain {
t.Errorf("Error renaming domain: Domain does not match")
}
}

Expand All @@ -54,6 +59,9 @@ func TestListDomains(t *testing.T) {
}
client, _, teardown, err := setupDomain(t, "fixtures/TestListDomains")
defer teardown()
if err != nil {
t.Error(err)
}

domains, err := client.ListDomains(context.Background(), nil)
if err != nil {
Expand All @@ -70,6 +78,9 @@ func TestGetDomain(t *testing.T) {
}
client, domain, teardown, err := setupDomain(t, "fixtures/TestGetDomain")
defer teardown()
if err != nil {
t.Error(err)
}

_, err = client.GetDomain(context.Background(), domain.ID)
if err != nil {
Expand Down
Loading

0 comments on commit e7e4839

Please sign in to comment.