From 26f2eddaa3105a32b3c1747d839d5583ecef84f9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 19 Aug 2019 15:57:24 +0200 Subject: [PATCH] integration/config: combine TestConfigCreateWithLabels with TestConfigsCreateAndDelete Signed-off-by: Sebastiaan van Stijn --- integration/config/config_test.go | 42 ++++++++++--------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/integration/config/config_test.go b/integration/config/config_test.go index 1c4580ee5b..3bf46bc248 100644 --- a/integration/config/config_test.go +++ b/integration/config/config_test.go @@ -140,21 +140,31 @@ func TestConfigsCreateAndDelete(t *testing.T) { ctx := context.Background() testName := "test_config-" + t.Name() - - // This test case is ported from the original TestConfigsCreate configID := createConfig(ctx, t, c, testName, []byte("TESTINGDATA"), nil) insp, _, err := c.ConfigInspectWithRaw(ctx, configID) assert.NilError(t, err) assert.Check(t, is.Equal(insp.Spec.Name, testName)) - // This test case is ported from the original TestConfigsDelete err = c.ConfigRemove(ctx, configID) assert.NilError(t, err) _, _, err = c.ConfigInspectWithRaw(ctx, configID) assert.Check(t, errdefs.IsNotFound(err)) assert.Check(t, is.ErrorContains(err, configID)) + + testName = "test_secret_with_labels_" + t.Name() + configID = createConfig(ctx, t, c, testName, []byte("TESTINGDATA"), map[string]string{ + "key1": "value1", + "key2": "value2", + }) + + insp, _, err = c.ConfigInspectWithRaw(ctx, configID) + assert.NilError(t, err) + assert.Check(t, is.Equal(insp.Spec.Name, testName)) + assert.Check(t, is.Equal(len(insp.Spec.Labels), 2)) + assert.Check(t, is.Equal(insp.Spec.Labels["key1"], "value1")) + assert.Check(t, is.Equal(insp.Spec.Labels["key2"], "value2")) } func TestConfigsUpdate(t *testing.T) { @@ -318,32 +328,6 @@ func TestTemplatedConfig(t *testing.T) { assertAttachedStream(t, attach, "tmpfs on /templated_config type tmpfs") } -func TestConfigCreateWithLabels(t *testing.T) { - skip.If(t, testEnv.DaemonInfo.OSType != "linux") - - defer setupTest(t)() - d := swarm.NewSwarm(t, testEnv) - defer d.Stop(t) - c := d.NewClientT(t) - defer c.Close() - - ctx := context.Background() - - labels := map[string]string{ - "key1": "value1", - "key2": "value2", - } - testName := t.Name() - configID := createConfig(ctx, t, c, testName, []byte("TESTINGDATA"), labels) - - insp, _, err := c.ConfigInspectWithRaw(ctx, configID) - assert.NilError(t, err) - assert.Check(t, is.Equal(insp.Spec.Name, testName)) - assert.Check(t, is.Equal(2, len(insp.Spec.Labels))) - assert.Check(t, is.Equal("value1", insp.Spec.Labels["key1"])) - assert.Check(t, is.Equal("value2", insp.Spec.Labels["key2"])) -} - // Test case for 28884 func TestConfigCreateResolve(t *testing.T) { skip.If(t, testEnv.DaemonInfo.OSType != "linux")