File: nodebalancer_stats_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 (36 lines) | stat: -rw-r--r-- 822 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
package unit

import (
	"context"
	"testing"

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

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

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

	base.MockGet("nodebalancers/123/stats", fixtureData)

	stats, err := base.Client.GetNodeBalancerStats(context.Background(), 123)

	// Assertions
	assert.NoError(t, err)
	assert.NotNil(t, stats)

	assert.Equal(t, "NodeBalancer Stats", stats.Title)

	assert.Len(t, stats.Data.Connections, 2)
	assert.Len(t, stats.Data.Connections[0], 2)

	assert.Len(t, stats.Data.Traffic.In, 2)
	assert.Len(t, stats.Data.Traffic.Out, 2)

	assert.Equal(t, 1000.0, stats.Data.Traffic.In[0][0])
	assert.Equal(t, 500.0, stats.Data.Traffic.Out[0][0])
}