Fix additional vet warnings

This commit is contained in:
James Nugent 2016-02-17 11:39:12 -08:00
parent bac909fdbf
commit bc6107508d
6 changed files with 16 additions and 35 deletions

View File

@ -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

View File

@ -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)
@ -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)

View File

@ -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)
@ -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)

View File

@ -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)
@ -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)

View File

@ -8,6 +8,8 @@ import (
"reflect"
"sync"
"testing"
"github.com/mitchellh/hashstructure"
)
func TestReadWriteStateV1(t *testing.T) {
@ -25,7 +27,10 @@ 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 {
@ -33,7 +38,11 @@ func TestReadWriteStateV1(t *testing.T) {
}
// 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!")
}

View File

@ -1,10 +1,6 @@
package terraform
import (
"bytes"
"crypto/sha1"
"encoding/gob"
"encoding/hex"
"fmt"
"io/ioutil"
"os"
@ -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 {