From 49e8a1823ee57f33d4bc03b1f79f5499b5a64dea Mon Sep 17 00:00:00 2001 From: Baptiste Foy Date: Wed, 14 Sep 2022 15:19:27 +0200 Subject: [PATCH] chore(tests): Add tests to validate the new behaviour Signed-off-by: Baptiste Foy --- client/delegations_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/delegations_test.go b/client/delegations_test.go index 47fdc229..6d5a7767 100644 --- a/client/delegations_test.go +++ b/client/delegations_test.go @@ -226,17 +226,27 @@ func TestPersistedMeta(t *testing.T) { p, err := c.local.GetMeta() assert.Nil(t, err) persisted := copyStore(p) + persistedLocal := copyStore(c.localMeta) // trim non targets metas for _, notTargets := range []string{"root.json", "snapshot.json", "timestamp.json"} { delete(persisted, notTargets) + delete(persistedLocal, notTargets) } for _, targets := range tt.targets { + // Test local store storedVersion, err := versionOfStoredTargets(targets.name, persisted) assert.Equal(t, targets.version, storedVersion) assert.Nil(t, err) delete(persisted, targets.name) + + // Test localMeta + storedVersion, err = versionOfStoredTargets(targets.name, persistedLocal) + assert.Equal(t, targets.version, storedVersion) + assert.Nil(t, err) + delete(persistedLocal, targets.name) } assert.Empty(t, persisted) + assert.Empty(t, persistedLocal) }) } }