mirror of
https://github.com/project-zot/zot.git
synced 2025-01-27 23:01:43 -05:00
5bf8c42e1f
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
24 lines
783 B
Go
24 lines
783 B
Go
package cluster_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
"zotregistry.dev/zot/pkg/cluster"
|
|
)
|
|
|
|
func TestComputeTargetMember(t *testing.T) {
|
|
Convey("Should panic when the hashKey is not long enough", t, func() {
|
|
So(func() { cluster.ComputeTargetMember("lorem", []string{"member1", "member2"}, "zot-test") }, ShouldPanic)
|
|
})
|
|
|
|
Convey("Should panic when there are no members", t, func() {
|
|
So(func() { cluster.ComputeTargetMember("loremipsumdolors", []string{}, "zot-test") }, ShouldPanic)
|
|
})
|
|
|
|
Convey("Should return a valid result when input is valid", t, func() {
|
|
index, member := cluster.ComputeTargetMember("loremipsumdolors", []string{"member1", "member2"}, "zot-test")
|
|
So(index, ShouldEqual, 1)
|
|
So(member, ShouldEqual, "member2")
|
|
})
|
|
}
|