Skip to content

Commit

Permalink
fix: change ci integration
Browse files Browse the repository at this point in the history
  • Loading branch information
marinsalinas committed Apr 18, 2019
1 parent 50a0d83 commit f814625
Show file tree
Hide file tree
Showing 267 changed files with 37,224 additions and 7,441 deletions.
37 changes: 14 additions & 23 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,21 @@ linters-settings:
linters:
enable-all: true
disable:
# - gocyclo
# # disabled gocyclo as we do have a lot of large methods to iterate thru the large JSON specs
# - dupl
# # disabled dupl as we do have a lot of duplicated code between resources and their tests, which gets flagged by this
# - errcheck
# # errocheck disabled to silience errors here: https://travis-ci.com/nutanix/terraform-provider-nutanix/jobs/131154435
# # Example error:
# # nutanix/data_source_nutanix_image.go:61:7: Error return value of `d.Set` is not checked (errcheck)
# # d.Set("name", utils.StringValue(resp.Status.Name))
# # waiting on terraform/hashi to let us know how they want us to changle those errors
# # see Error return value of `d.Set` is not checked (errcheck)
# - typecheck
- deadcode
- gocyclo
# disabled gocyclo as we do have a lot of large methods to iterate thru the large JSON specs
- dupl
# disabled dupl as we do have a lot of duplicated code between resources and their tests, which gets flagged by this
- errcheck
- gofmt
- gosimple
- ineffassign
- misspell
- staticcheck
- structcheck
- unconvert
- unused
- varcheck
- vet
# errocheck disabled to silience errors here: https://travis-ci.com/nutanix/terraform-provider-nutanix/jobs/131154435
# Example error:
# nutanix/data_source_nutanix_image.go:61:7: Error return value of `d.Set` is not checked (errcheck)
# d.Set("name", utils.StringValue(resp.Status.Name))
# waiting on terraform/hashi to let us know how they want us to changle those errors
# see Error return value of `d.Set` is not checked (errcheck)
- typecheck
- gosec
- gochecknoinits
- gochecknoglobals

issues:
exclude:
Expand Down
4 changes: 2 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ lint: fmtcheck
@GOGC=30 golangci-lint run

tools:
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell
GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint


vet:
Expand Down
44 changes: 20 additions & 24 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,14 @@ import (
"testing"
)

var (
mux *http.ServeMux
func setup() (*http.ServeMux, *Client, *httptest.Server) {
mux := http.NewServeMux()
server := httptest.NewServer(mux)

ctx = context.TODO()

client *Client

server *httptest.Server
)

func setup() {
mux = http.NewServeMux()
server = httptest.NewServer(mux)

client, _ = NewClient(&Credentials{"", "username", "password", "", "", true, ""})
client, _ := NewClient(&Credentials{"", "username", "password", "", "", true, ""})
client.BaseURL, _ = url.Parse(server.URL)
}

func teardown() {
server.Close()
return mux, client, server
}

func TestNewClient(t *testing.T) {
Expand Down Expand Up @@ -62,7 +50,7 @@ func TestNewRequest(t *testing.T) {
inURL, outURL := "/foo", fmt.Sprintf(defaultBaseURL+absolutePath+"/foo", "foo.com")
inBody, outBody := map[string]interface{}{"name": "bar"}, `{"name":"bar"}`+"\n"

req, _ := c.NewRequest(ctx, http.MethodPost, inURL, inBody)
req, _ := c.NewRequest(context.TODO(), http.MethodPost, inURL, inBody)

// test relative URL was expanded
if req.URL.String() != outURL {
Expand Down Expand Up @@ -128,8 +116,9 @@ func TestCheckResponse(t *testing.T) {
}

func TestDo(t *testing.T) {
setup()
defer teardown()
ctx := context.TODO()
mux, client, server := setup()
defer server.Close()

type foo struct {
A string
Expand Down Expand Up @@ -159,8 +148,9 @@ func TestDo(t *testing.T) {
}

func TestDo_httpError(t *testing.T) {
setup()
defer teardown()
ctx := context.TODO()
mux, client, server := setup()
defer server.Close()

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Bad Request", 400)
Expand All @@ -177,8 +167,9 @@ func TestDo_httpError(t *testing.T) {
// / Test handling of an error caused by the internal http client's Do()
// function.
func TestDo_redirectLoop(t *testing.T) {
setup()
defer teardown()
ctx := context.TODO()
mux, client, server := setup()
defer server.Close()

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/", http.StatusFound)
Expand Down Expand Up @@ -266,6 +257,7 @@ func TestClient_NewRequest(t *testing.T) {
// TODO: Add test cases.
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
c := &Client{
Credentials: tt.fields.Credentials,
Expand Down Expand Up @@ -310,6 +302,7 @@ func TestClient_NewUploadRequest(t *testing.T) {
// TODO: Add test cases.
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
c := &Client{
Credentials: tt.fields.Credentials,
Expand Down Expand Up @@ -349,6 +342,7 @@ func TestClient_OnRequestCompleted(t *testing.T) {
// TODO: Add test cases.
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
c := &Client{
Credentials: tt.fields.Credentials,
Expand Down Expand Up @@ -384,6 +378,7 @@ func TestClient_Do(t *testing.T) {
// TODO: Add test cases.
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
c := &Client{
Credentials: tt.fields.Credentials,
Expand Down Expand Up @@ -412,6 +407,7 @@ func Test_fillStruct(t *testing.T) {
// TODO: Add test cases.
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if err := fillStruct(tt.args.data, tt.args.result); (err != nil) != tt.wantErr {
t.Errorf("fillStruct() error = %v, wantErr %v", err, tt.wantErr)
Expand Down
56 changes: 48 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,33 +1,73 @@
module github.com/terraform-providers/terraform-provider-nutanix

require (
github.com/OpenPeeDeeP/depguard v0.0.0-20181229194401-1f388ab2d810 // indirect
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 // indirect
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/client9/misspell v0.3.4 // indirect
github.com/coreos/etcd v3.3.12+incompatible // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/go-critic/go-critic v0.3.4 // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-toolsmith/astcast v1.0.0 // indirect
github.com/go-toolsmith/astcopy v1.0.0 // indirect
github.com/go-toolsmith/astfmt v1.0.0 // indirect
github.com/go-toolsmith/astp v1.0.0 // indirect
github.com/go-toolsmith/pkgload v1.0.0 // indirect
github.com/go-toolsmith/typep v1.0.0 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang/mock v1.2.0 // indirect
github.com/golang/protobuf v1.3.1 // indirect
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6 // indirect
github.com/golangci/go-tools v0.0.0-20190124090046-35a9f45a5db0 // indirect
github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d // indirect
github.com/golangci/gofmt v0.0.0-20181222123516-0b8337e80d98 // indirect
github.com/golangci/golangci-lint v1.16.0 // indirect
github.com/golangci/gosec v0.0.0-20180901114220-8afd9cbb6cfb // indirect
github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219 // indirect
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 // indirect
github.com/hashicorp/go-getter v0.0.0-20180809191950-4bda8fa99001 // indirect
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd // indirect
github.com/hashicorp/go-plugin v0.0.0-20180331002553-e8d22c780116 // indirect
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect
github.com/hashicorp/hcl2 v0.0.0-20180810011014-6743a2254ba3 // indirect
github.com/hashicorp/terraform v0.11.14-0.20190313165547-28810e6c0c0a
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect
github.com/kisielk/errcheck v1.2.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/pty v1.1.4 // indirect
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.7 // indirect
github.com/mitchellh/cli v0.0.0-20180414170447-c48282d14eba // indirect
github.com/mitchellh/go-homedir v0.0.0-20180801233206-58046073cbff // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452 // indirect
github.com/mitchellh/mapstructure v0.0.0-20180715050151-f15292f7a699 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/pelletier/go-toml v1.3.0 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/posener/complete v1.1.1 // indirect
github.com/rogpeppe/go-internal v1.3.0 // indirect
github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil v2.18.12+incompatible // indirect
github.com/shurcooL/go v0.0.0-20190330031554-6713ea532688 // indirect
github.com/sirupsen/logrus v1.4.1 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cobra v0.0.3 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.3.2 // indirect
github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 // indirect
github.com/zclconf/go-cty v0.0.0-20180718220526-02bd58e97b57 // indirect
golang.org/x/crypto v0.0.0-20180808211826-de0752318171 // indirect
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5 // indirect
golang.org/x/net v0.0.0-20190403144856-b630fd6fe46b // indirect
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 // indirect
golang.org/x/tools v0.0.0-20190404132500-923d25813098 // indirect
google.golang.org/genproto v0.0.0-20180808183934-383e8b2c3b9e // indirect
google.golang.org/grpc v1.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
mvdan.cc/unparam v0.0.0-20190310220240-1b9ccfa71afe // indirect
sourcegraph.com/sqs/pbtypes v1.0.0 // indirect
)
Loading

0 comments on commit f814625

Please sign in to comment.