Skip to content

Commit

Permalink
Fix additional vet warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jen20 committed Feb 17, 2016
1 parent bac909f commit bc61075
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TEST?=$$(GO15VENDOREXPERIMENT=1 go list ./... | grep -v /vendor/)
VETARGS?=-asmdecl -atomic -bool -buildtags -composites -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr -unusedresult
VETARGS?=-asmdecl -atomic -bool -buildtags -composites -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unreachable -unsafeptr -unusedresult

default: test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccAWSGroupMembership_basic(t *testing.T) {

rString := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
configBase := fmt.Sprintf(testAccAWSGroupMemberConfig, rString, rString, rString)
configUpdate := fmt.Sprintf(testAccAWSGroupMemberConfigUpdate, rString, rString, rString, rString)
configUpdate := fmt.Sprintf(testAccAWSGroupMemberConfigUpdate, rString, rString, rString, rString, rString)
configUpdateDown := fmt.Sprintf(testAccAWSGroupMemberConfigUpdateDown, rString, rString, rString)

testUser := fmt.Sprintf("test-user-%s", rString)
Expand Down Expand Up @@ -115,7 +115,7 @@ func testAccCheckAWSGroupMembershipExists(n string, g *iam.GetGroupOutput) resou
func testAccCheckAWSGroupMembershipAttributes(group *iam.GetGroupOutput, users []string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if !strings.Contains(*group.Group.GroupName, "test-group") {
return fmt.Errorf("Bad group membership: expected %d, got %d", "test-group", *group.Group.GroupName)
return fmt.Errorf("Bad group membership: expected %s, got %s", "test-group", *group.Group.GroupName)
}

uc := len(users)
Expand Down
4 changes: 2 additions & 2 deletions builtin/providers/vsphere/resource_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ func (vm *virtualMachine) createVirtualMachine(c *govmomi.Client) error {

if d.Type == "StoragePod" {
sp := object.StoragePod{
object.NewFolder(c.Client, d),
Folder: object.NewFolder(c.Client, d),
}
sps := buildStoragePlacementSpecCreate(dcFolders, resourcePool, sp, configSpec)
datastore, err = findDatastore(c, sps)
Expand Down Expand Up @@ -1054,7 +1054,7 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {

if d.Type == "StoragePod" {
sp := object.StoragePod{
object.NewFolder(c.Client, d),
Folder: object.NewFolder(c.Client, d),
}
sps := buildStoragePlacementSpecClone(c, dcFolders, template, resourcePool, sp)
datastore, err = findDatastore(c, sps)
Expand Down
9 changes: 0 additions & 9 deletions terraform/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,6 @@ func TestReadWriteState(t *testing.T) {
},
}

// Checksum before the write
chksum := checksumStruct(t, state)

buf := new(bytes.Buffer)
if err := WriteState(state, buf); err != nil {
t.Fatalf("err: %s", err)
Expand All @@ -808,12 +805,6 @@ func TestReadWriteState(t *testing.T) {
t.Fatalf("bad version number: %d", state.Version)
}

// Checksum after the write
chksumAfter := checksumStruct(t, state)
if chksumAfter != chksum {
t.Fatalf("structure changed during serialization!")
}

actual, err := ReadState(buf)
if err != nil {
t.Fatalf("err: %s", err)
Expand Down
13 changes: 11 additions & 2 deletions terraform/state_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"reflect"
"sync"
"testing"

"github.com/mitchellh/hashstructure"
)

func TestReadWriteStateV1(t *testing.T) {
Expand All @@ -25,15 +27,22 @@ func TestReadWriteStateV1(t *testing.T) {
}

// Checksum before the write
chksum := checksumStruct(t, state)
chksum, err := hashstructure.Hash(state, nil)
if err != nil {
t.Fatalf("hash: %s", err)
}

buf := new(bytes.Buffer)
if err := testWriteStateV1(state, buf); err != nil {
t.Fatalf("err: %s", err)
}

// Checksum after the write
chksumAfter := checksumStruct(t, state)
chksumAfter, err := hashstructure.Hash(state, nil)
if err != nil {
t.Fatalf("hash: %s", err)
}

if chksumAfter != chksum {
t.Fatalf("structure changed during serialization!")
}
Expand Down
19 changes: 0 additions & 19 deletions terraform/terraform_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package terraform

import (
"bytes"
"crypto/sha1"
"encoding/gob"
"encoding/hex"
"fmt"
"io/ioutil"
"os"
Expand All @@ -21,21 +17,6 @@ import (
// This is the directory where our test fixtures are.
const fixtureDir = "./test-fixtures"

func checksumStruct(t *testing.T, i interface{}) string {
// TODO(mitchellh): write a library to do this because gob is not
// deterministic in order
return "foo"

buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf)
if err := enc.Encode(i); err != nil {
t.Fatalf("err: %s", err)
}

sum := sha1.Sum(buf.Bytes())
return hex.EncodeToString(sum[:])
}

func tempDir(t *testing.T) string {
dir, err := ioutil.TempDir("", "tf")
if err != nil {
Expand Down

0 comments on commit bc61075

Please sign in to comment.