Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Add tests for remove App by id
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe Sirot <[email protected]>
  • Loading branch information
Jean-Christophe Sirot committed Nov 13, 2019
1 parent e436fbe commit 1768d47
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions internal/store/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,44 @@ func TestRemove(t *testing.T) {
})
}

func TestRemoveById(t *testing.T) {
dockerConfigDir := fs.NewDir(t, t.Name(), fs.WithMode(0755))
defer dockerConfigDir.Remove()
appstore, err := NewApplicationStore(dockerConfigDir.Path())
assert.NilError(t, err)
bundleStore, err := appstore.BundleStore()
assert.NilError(t, err)

t.Run("error on multiple repositories", func(t *testing.T) {
bndl := relocated.FromBundle(&bundle.Bundle{Name: "bundle-name"})
idRef, err := FromBundle(bndl)
assert.NilError(t, err)
_, err = bundleStore.Store(idRef, bndl)
assert.NilError(t, err)
_, err = bundleStore.Store(parseRefOrDie(t, "my-repo/a-bundle:my-tag"), bndl)
assert.NilError(t, err)

err = bundleStore.Remove(idRef)
assert.Equal(t, err.Error(), fmt.Sprintf("unable to delete %s - App is referenced in multiple repositories", reference.FamiliarString(idRef)))
})

t.Run("success when only one reference exists", func(t *testing.T) {
bndl := relocated.FromBundle(&bundle.Bundle{Name: "other-bundle-name"})
ref := parseRefOrDie(t, "my-repo/other-bundle:my-tag")
_, err = bundleStore.Store(ref, bndl)

idRef, err := FromBundle(bndl)
assert.NilError(t, err)

err = bundleStore.Remove(idRef)
assert.NilError(t, err)
bundles, err := bundleStore.List()
assert.NilError(t, err)
for _, bref := range bundles {
assert.Equal(t, bref == ref, false)
}
})
}
func TestLookUp(t *testing.T) {
dockerConfigDir := fs.NewDir(t, t.Name(), fs.WithMode(0755))
defer dockerConfigDir.Remove()
Expand Down

0 comments on commit 1768d47

Please sign in to comment.