File: client_device_test.go

package info (click to toggle)
golang-github-koofr-go-koofrclient 0.0~git20190724.8e5366d-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 124 kB
  • sloc: makefile: 5
file content (52 lines) | stat: -rw-r--r-- 1,376 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package koofrclient_test

import (
	"fmt"
	k "github.com/koofr/go-koofrclient"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"time"
)

var _ = Describe("ClientDevice", func() {
	testDeviceName := fmt.Sprintf("Test %s", time.Now())
	var device k.Device

	It("should list devices", func() {
		devices, err := client.Devices()
		Expect(err).NotTo(HaveOccurred())
		Expect(devices).NotTo(BeEmpty())
	})

	It("should create new device", func() {
		var err error
		device, err = client.DevicesCreate(testDeviceName, k.StorageHubProvider)
		Expect(err).NotTo(HaveOccurred())
		Expect(device.Name).NotTo(BeEmpty())
	})

	It("should get device details", func() {
		Expect(device).NotTo(BeNil())
		deviceDetails, err := client.DevicesDetails(device.Id)
		Expect(err).NotTo(HaveOccurred())
		Expect(deviceDetails).NotTo(BeNil())
		Expect(deviceDetails).To(Equal(device))
	})

	It("should update device", func() {
		newName := "NewName"
		Expect(device).NotTo(BeNil())
		err := client.DevicesUpdate(device.Id, k.DeviceUpdate{Name: newName})
		Expect(err).NotTo(HaveOccurred())
		deviceDetails, err := client.DevicesDetails(device.Id)
		Expect(err).NotTo(HaveOccurred())
		Expect(deviceDetails.Name).To(Equal(newName))

	})

	It("should delete device", func() {
		Expect(device).NotTo(BeNil())
		err := client.DevicesDelete(device.Id)
		Expect(err).NotTo(HaveOccurred())
	})
})