fixed:go vetting warning unkeyed fields

Signed-off-by: Aaron.L.Xu <liker.xu@foxmail.com>
This commit is contained in:
liker12134 2017-03-20 16:27:51 +08:00 committed by Aaron.L.Xu
parent 04da404175
commit 2333b39b37
9 changed files with 47 additions and 48 deletions

View File

@ -8,7 +8,7 @@ import (
func TestCalculateBlockIO(t *testing.T) {
blkio := types.BlkioStats{
IoServiceBytesRecursive: []types.BlkioStatEntry{{8, 0, "read", 1234}, {8, 1, "read", 4567}, {8, 0, "write", 123}, {8, 1, "write", 456}},
IoServiceBytesRecursive: []types.BlkioStatEntry{{Major: 8, Minor: 0, Op: "read", Value: 1234}, {Major: 8, Minor: 1, Op: "read", Value: 4567}, {Major: 8, Minor: 0, Op: "write", Value: 123}, {Major: 8, Minor: 1, Op: "write", Value: 456}},
}
blkRead, blkWrite := calculateBlockIO(blkio)
if blkRead != 5801 {

View File

@ -24,10 +24,10 @@ func (s *DockerSwarmSuite) TestAPISwarmSecretsCreate(c *check.C) {
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
@ -41,11 +41,10 @@ func (s *DockerSwarmSuite) TestAPISwarmSecretsDelete(c *check.C) {
d := s.AddDaemon(c, true, true)
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
id := d.CreateSecret(c, swarm.SecretSpec{Annotations: swarm.Annotations{
Name: testName,
},
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
@ -63,13 +62,13 @@ func (s *DockerSwarmSuite) TestAPISwarmSecretsUpdate(c *check.C) {
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: testName,
Labels: map[string]string{
"test": "test1",
},
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))

View File

@ -17,10 +17,10 @@ func (s *DockerSwarmSuite) TestSecretCreate(c *check.C) {
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
@ -33,14 +33,14 @@ func (s *DockerSwarmSuite) TestSecretCreateWithLabels(c *check.C) {
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: testName,
Labels: map[string]string{
"key1": "value1",
"key2": "value2",
},
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
@ -57,18 +57,18 @@ func (s *DockerSwarmSuite) TestSecretCreateResolve(c *check.C) {
name := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: name,
},
[]byte("foo"),
Data: []byte("foo"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
fake := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: id,
},
[]byte("fake foo"),
Data: []byte("fake foo"),
})
c.Assert(fake, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", fake))

View File

@ -15,10 +15,10 @@ func (s *DockerSwarmSuite) TestSecretInspect(c *check.C) {
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
@ -42,10 +42,10 @@ func (s *DockerSwarmSuite) TestSecretInspectMultiple(c *check.C) {
}
for _, n := range testNames {
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: n,
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))

View File

@ -68,10 +68,10 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *check.C) {
serviceName := "test-service-secret"
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
@ -98,10 +98,10 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTarget(c *check.C) {
serviceName := "test-service-secret"
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
testTarget := "testing"

View File

@ -91,10 +91,10 @@ func (s *DockerSwarmSuite) TestServiceUpdateSecrets(c *check.C) {
d := s.AddDaemon(c, true, true)
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Annotations: swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
Data: []byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
testTarget := "testing"

View File

@ -14,33 +14,33 @@ func TestValidatePrivileges(t *testing.T) {
}{
"diff-len": {
requiredPrivileges: []types.PluginPrivilege{
{"Privilege1", "Description", []string{"abc", "def", "ghi"}},
{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "ghi"}},
},
privileges: []types.PluginPrivilege{
{"Privilege1", "Description", []string{"abc", "def", "ghi"}},
{"Privilege2", "Description", []string{"123", "456", "789"}},
{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "ghi"}},
{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "789"}},
},
result: false,
},
"diff-value": {
requiredPrivileges: []types.PluginPrivilege{
{"Privilege1", "Description", []string{"abc", "def", "GHI"}},
{"Privilege2", "Description", []string{"123", "456", "***"}},
{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "GHI"}},
{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "***"}},
},
privileges: []types.PluginPrivilege{
{"Privilege1", "Description", []string{"abc", "def", "ghi"}},
{"Privilege2", "Description", []string{"123", "456", "789"}},
{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "ghi"}},
{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "789"}},
},
result: false,
},
"diff-order-but-same-value": {
requiredPrivileges: []types.PluginPrivilege{
{"Privilege1", "Description", []string{"abc", "def", "GHI"}},
{"Privilege2", "Description", []string{"123", "456", "789"}},
{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "GHI"}},
{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "789"}},
},
privileges: []types.PluginPrivilege{
{"Privilege2", "Description", []string{"123", "456", "789"}},
{"Privilege1", "Description", []string{"GHI", "abc", "def"}},
{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "789"}},
{Name: "Privilege1", Description: "Description", Value: []string{"GHI", "abc", "def"}},
},
result: true,
},

View File

@ -9,8 +9,8 @@ import (
func TestFilterByCapNeg(t *testing.T) {
p := v2.Plugin{PluginObj: types.Plugin{Name: "test:latest"}}
iType := types.PluginInterfaceType{"volumedriver", "docker", "1.0"}
i := types.PluginConfigInterface{"plugins.sock", []types.PluginInterfaceType{iType}}
iType := types.PluginInterfaceType{Capability: "volumedriver", Prefix: "docker", Version: "1.0"}
i := types.PluginConfigInterface{Socket: "plugins.sock", Types: []types.PluginInterfaceType{iType}}
p.PluginObj.Config.Interface = i
_, err := p.FilterByCap("foobar")
@ -22,8 +22,8 @@ func TestFilterByCapNeg(t *testing.T) {
func TestFilterByCapPos(t *testing.T) {
p := v2.Plugin{PluginObj: types.Plugin{Name: "test:latest"}}
iType := types.PluginInterfaceType{"volumedriver", "docker", "1.0"}
i := types.PluginConfigInterface{"plugins.sock", []types.PluginInterfaceType{iType}}
iType := types.PluginInterfaceType{Capability: "volumedriver", Prefix: "docker", Version: "1.0"}
i := types.PluginConfigInterface{Socket: "plugins.sock", Types: []types.PluginInterfaceType{iType}}
p.PluginObj.Config.Interface = i
_, err := p.FilterByCap("volumedriver")

View File

@ -167,11 +167,11 @@ func TestPidModeTest(t *testing.T) {
func TestRestartPolicy(t *testing.T) {
restartPolicies := map[container.RestartPolicy][]bool{
// none, always, failure
container.RestartPolicy{}: {true, false, false},
container.RestartPolicy{"something", 0}: {false, false, false},
container.RestartPolicy{"no", 0}: {true, false, false},
container.RestartPolicy{"always", 0}: {false, true, false},
container.RestartPolicy{"on-failure", 0}: {false, false, true},
container.RestartPolicy{}: {true, false, false},
container.RestartPolicy{Name: "something", MaximumRetryCount: 0}: {false, false, false},
container.RestartPolicy{Name: "no", MaximumRetryCount: 0}: {true, false, false},
container.RestartPolicy{Name: "always", MaximumRetryCount: 0}: {false, true, false},
container.RestartPolicy{Name: "on-failure", MaximumRetryCount: 0}: {false, false, true},
}
for restartPolicy, state := range restartPolicies {
if restartPolicy.IsNone() != state[0] {