mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-22 16:34:32 +01:00
f3734ed0d4
- endpoint abstractions now share an interface `Abstraction` - pkg endpoint now has a query facitilty (`ListAbstractions`) which is used to find on-disk - step holds and bookmarks - replication cursors (v1, v2) - last-received-holds - the `zrepl holds list` command consumes endpoint.ListAbstractions - the new `zrepl holds release-{all,stale}` commands can be used to remove abstractions of package endpoint Co-authored-by: InsanePrawn <insane.prawny@gmail.com> supersedes #282 fixes #280 fixes #278
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package endpoint
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseJobAndGuidBookmarkName(t *testing.T) {
|
|
|
|
type Case struct {
|
|
input string
|
|
expectErr bool
|
|
|
|
guid uint64
|
|
jobid string
|
|
}
|
|
|
|
cases := []Case{
|
|
{
|
|
`p1/sync#zrepl_CURSOR_G_932f3a7089080ce2_J_push with legitimate name`,
|
|
false, 0x932f3a7089080ce2, "push with legitimate name",
|
|
},
|
|
{
|
|
input: `p1/sync#zrepl_CURSOR_G_932f3a7089_J_push with legitimate name`,
|
|
expectErr: true,
|
|
},
|
|
{
|
|
input: `p1/sync#zrepl_CURSOR_G_932f3a7089080ce2_J_push with il\tlegitimate name`,
|
|
expectErr: true,
|
|
},
|
|
{
|
|
input: `p1/sync#otherprefix_G_932f3a7089080ce2_J_push with legitimate name`,
|
|
expectErr: true,
|
|
},
|
|
}
|
|
|
|
for i := range cases {
|
|
t.Run(cases[i].input, func(t *testing.T) {
|
|
guid, jobid, err := parseJobAndGuidBookmarkName(cases[i].input, replicationCursorBookmarkNamePrefix)
|
|
if cases[i].expectErr {
|
|
assert.Error(t, err)
|
|
} else {
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, cases[i].guid, guid)
|
|
assert.Equal(t, MustMakeJobID(cases[i].jobid), jobid)
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|