File: maintenance_policy_test.go

package info (click to toggle)
golang-github-linode-linodego 1.55.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,112 kB
  • sloc: makefile: 96; sh: 52; python: 24
file content (42 lines) | stat: -rw-r--r-- 1,411 bytes parent folder | download
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
package unit

import (
	"context"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestMaintenancePolicies_List(t *testing.T) {
	fixtureData, err := fixtures.GetFixture("maintenance_policies_list")
	assert.NoError(t, err)

	var base ClientBaseCase
	base.SetUp(t)
	defer base.TearDown(t)

	base.MockGet("maintenance/policies", fixtureData)

	policies, err := base.Client.ListMaintenancePolicies(context.Background(), nil)
	assert.NoError(t, err)

	assert.Len(t, policies, 2, "Expected two maintenance policies to be returned")

	assert.Equal(t, "linode/migrate", policies[0].Slug)
	assert.Equal(t, "Migrate", policies[0].Label)
	assert.Equal(t, "Migrates the Linode to a new host while it remains fully operational. Recommended for maximizing availability.", policies[0].Description)
	assert.Equal(t, "migrate", policies[0].Type)
	assert.Equal(t, 300, policies[0].NotificationPeriodSec)
	assert.Equal(t, true, policies[0].IsDefault)

	assert.Equal(t, "linode/power_off_on", policies[1].Slug)
	assert.Equal(t, "Power-off/on", policies[1].Label)
	assert.Equal(
		t,
		"Powers off the Linode at the start of the maintenance event and reboots it once the maintenance finishes. Recommended for maximizing performance.",
		policies[1].Description,
	)
	assert.Equal(t, "power_off_on", policies[1].Type)
	assert.Equal(t, 1800, policies[1].NotificationPeriodSec)
	assert.Equal(t, false, policies[1].IsDefault)
}