1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration/secret/secret_test.go
Yong Tang 71c794d912 Migrate TestSecretInspect from integration-cli to api tests
This fix migrates TestSecretInspect from integration-cli to api tests

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-02-02 22:23:12 +00:00

43 lines
1.2 KiB
Go

package secret
import (
"testing"
swarmtypes "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/integration-cli/request"
"github.com/docker/docker/integration/util/swarm"
"github.com/gotestyourself/gotestyourself/skip"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
)
func TestSecretInspect(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType != "linux")
defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t)
client, err := request.NewClientForHost(d.Sock())
require.NoError(t, err)
ctx := context.Background()
testName := "test_secret"
secretResp, err := client.SecretCreate(ctx, swarmtypes.SecretSpec{
Annotations: swarmtypes.Annotations{
Name: testName,
},
Data: []byte("TESTINGDATA"),
})
require.NoError(t, err)
assert.NotEqual(t, secretResp.ID, "")
secret, _, err := client.SecretInspectWithRaw(context.Background(), secretResp.ID)
require.NoError(t, err)
assert.Equal(t, secret.Spec.Name, testName)
secret, _, err = client.SecretInspectWithRaw(context.Background(), testName)
require.NoError(t, err)
assert.Equal(t, secret.ID, secretResp.ID)
}