func TestKoofrclient(t *testing.T) { RegisterFailHandler(Fail) apiBase = os.Getenv("KOOFR_APIBASE") if apiBase == "" { t.Fatal("Missing KOOFR_APIBASE") } email = os.Getenv("KOOFR_EMAIL") if email == "" { t.Fatal("Missing KOOFR_EMAIL") } password = os.Getenv("KOOFR_PASSWORD") if password == "" { t.Fatal("Missing KOOFR_PASSWORD") } client = k.NewKoofrClient(apiBase, true) err := client.Authenticate(email, password) if err != nil { t.Fatal("Koofr authorization failed") } mounts, err := client.Mounts() if err != nil { t.Fatal("Koofr listing mounts failed") } if len(mounts) == 0 { t.Fatal("Koofr mounts must not be empty") } for _, m := range mounts { if m.IsPrimary { defaultMountId = m.Id } } if defaultMountId == "" { t.Fatal("Koofr primary mount not found") } RunSpecs(t, "Koofrclient Suite") }
package koofrclient_test import ( k "github.com/koofr/go-koofrclient" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Client", func() { It("should create client with token", func() { c := k.NewKoofrClient(apiBase, true) Expect(c).NotTo(BeNil()) c.SetToken("eac6e8d7-edea-4af1-92db-9636795379d1") Expect(c).NotTo(BeNil()) }) It("should create client and authorize", func() { c := k.NewKoofrClient(apiBase, true) Expect(c).NotTo(BeNil()) err := c.Authenticate(email, password) Expect(err).NotTo(HaveOccurred()) Expect(c.GetToken()).To(HaveLen(36)) }) })