service_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright © 2021 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 service_test
  16. import (
  17. "time"
  18. client "github.com/mudler/edgevpn/api/client"
  19. . "github.com/onsi/ginkgo/v2"
  20. . "github.com/onsi/gomega"
  21. . "github.com/mudler/edgevpn/api/client/service"
  22. )
  23. var _ = Describe("Service", func() {
  24. c := client.NewClient(client.WithHost(testInstance))
  25. s := NewClient("foo", c)
  26. Context("Retrieves nodes", func() {
  27. PIt("Detect nodes", func() {
  28. Eventually(func() []string {
  29. n, _ := s.ActiveNodes()
  30. return n
  31. },
  32. 100*time.Second, 1*time.Second).ShouldNot(BeEmpty())
  33. })
  34. })
  35. Context("Advertize nodes", func() {
  36. It("Detect nodes", func() {
  37. n, err := s.AdvertizingNodes()
  38. Expect(len(n)).To(Equal(0))
  39. Expect(err).ToNot(HaveOccurred())
  40. s.Advertize("foo")
  41. Eventually(func() []string {
  42. n, _ := s.AdvertizingNodes()
  43. return n
  44. },
  45. 100*time.Second, 1*time.Second).Should(Equal([]string{"foo"}))
  46. })
  47. })
  48. })