Skip to content

Commit

Permalink
chore(tests): Add tests to validate the new behaviour
Browse files Browse the repository at this point in the history
Signed-off-by: Baptiste Foy <[email protected]>
  • Loading branch information
BaptisteFoy authored and trishankatdatadog committed Nov 2, 2022
1 parent 6a11f48 commit 1c24125
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/delegations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
Expand Down

0 comments on commit 1c24125

Please sign in to comment.