mirror of https://github.com/docker/cli.git
cli/context/store: TestTlsCreateUpdateGetRemove(): use correct ID
This test was depending on the fact that contextDir's are a string, and for the test is was using the context _name_ as a pseudo-ID. This patch updates the test to be more explicit where ID's and where names are used. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d0398c423f
commit
42e275eaf6
|
@ -8,26 +8,30 @@ import (
|
||||||
|
|
||||||
func TestTlsCreateUpdateGetRemove(t *testing.T) {
|
func TestTlsCreateUpdateGetRemove(t *testing.T) {
|
||||||
testee := tlsStore{root: t.TempDir()}
|
testee := tlsStore{root: t.TempDir()}
|
||||||
_, err := testee.getData("test-ctx", "test-ep", "test-data")
|
|
||||||
|
const contextName = "test-ctx"
|
||||||
|
contextID := contextdirOf(contextName)
|
||||||
|
|
||||||
|
_, err := testee.getData(contextID, "test-ep", "test-data")
|
||||||
assert.Equal(t, true, IsErrTLSDataDoesNotExist(err))
|
assert.Equal(t, true, IsErrTLSDataDoesNotExist(err))
|
||||||
|
|
||||||
err = testee.createOrUpdate("test-ctx", "test-ep", "test-data", []byte("data"))
|
err = testee.createOrUpdate(contextID, "test-ep", "test-data", []byte("data"))
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
data, err := testee.getData("test-ctx", "test-ep", "test-data")
|
data, err := testee.getData(contextID, "test-ep", "test-data")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, string(data), "data")
|
assert.Equal(t, string(data), "data")
|
||||||
err = testee.createOrUpdate("test-ctx", "test-ep", "test-data", []byte("data2"))
|
err = testee.createOrUpdate(contextID, "test-ep", "test-data", []byte("data2"))
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
data, err = testee.getData("test-ctx", "test-ep", "test-data")
|
data, err = testee.getData(contextID, "test-ep", "test-data")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, string(data), "data2")
|
assert.Equal(t, string(data), "data2")
|
||||||
|
|
||||||
err = testee.remove("test-ctx", "test-ep", "test-data")
|
err = testee.remove(contextID, "test-ep", "test-data")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
err = testee.remove("test-ctx", "test-ep", "test-data")
|
err = testee.remove(contextID, "test-ep", "test-data")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
_, err = testee.getData("test-ctx", "test-ep", "test-data")
|
_, err = testee.getData(contextID, "test-ep", "test-data")
|
||||||
assert.Equal(t, true, IsErrTLSDataDoesNotExist(err))
|
assert.Equal(t, true, IsErrTLSDataDoesNotExist(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue