2
0

leader_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright © 2022 Ettore Di Giacinto <[email protected]>
  2. //
  3. // This program is free software; you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation; either version 2 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License along
  14. // with this program; if not, see <http://www.gnu.org/licenses/>.
  15. package utils_test
  16. import (
  17. . "github.com/onsi/ginkgo/v2"
  18. . "github.com/onsi/gomega"
  19. . "github.com/mudler/edgevpn/pkg/utils"
  20. )
  21. var _ = Describe("Leader utilities", func() {
  22. Context("Leader", func() {
  23. It("returns the correct leader", func() {
  24. Expect(Leader([]string{"a", "b", "c", "d"})).To(Equal("b"))
  25. Expect(Leader([]string{"a", "b", "c", "d", "e", "f", "G", "bb"})).To(Equal("b"))
  26. Expect(Leader([]string{"a", "b", "c", "d", "e", "f", "G", "bb", "z", "b1", "b2"})).To(Equal("z"))
  27. Expect(Leader([]string{"1", "2", "3", "4", "5"})).To(Equal("2"))
  28. Expect(Leader([]string{"1", "2", "3", "4", "5", "6", "7", "21", "22"})).To(Equal("22"))
  29. })
  30. })
  31. })