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:
Sebastiaan van Stijn 2022-09-28 17:29:01 +02:00
parent d0398c423f
commit 42e275eaf6
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 12 additions and 8 deletions

View File

@ -8,26 +8,30 @@ import (
func TestTlsCreateUpdateGetRemove(t *testing.T) {
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))
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)
data, err := testee.getData("test-ctx", "test-ep", "test-data")
data, err := testee.getData(contextID, "test-ep", "test-data")
assert.NilError(t, err)
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)
data, err = testee.getData("test-ctx", "test-ep", "test-data")
data, err = testee.getData(contextID, "test-ep", "test-data")
assert.NilError(t, err)
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)
err = testee.remove("test-ctx", "test-ep", "test-data")
err = testee.remove(contextID, "test-ep", "test-data")
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))
}