-
Notifications
You must be signed in to change notification settings - Fork 32
/
list_handler_test.go
63 lines (48 loc) · 1.5 KB
/
list_handler_test.go
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
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2018 The agentx authors
// Licensed under the LGPLv3 with static-linking exception.
// See LICENCE file for details.
package agentx_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/posteo/go-agentx"
"github.com/posteo/go-agentx/pdu"
"github.com/posteo/go-agentx/value"
)
func TestListHandler(t *testing.T) {
e := setUpTestEnvironment(t)
defer e.tearDown()
session, err := e.client.Session()
require.NoError(t, err)
defer session.Close()
lh := &agentx.ListHandler{}
i := lh.Add("1.3.6.1.4.1.45995.3.1")
i.Type = pdu.VariableTypeOctetString
i.Value = "test"
session.Handler = lh
baseOID := value.MustParseOID("1.3.6.1.4.1.45995")
require.NoError(t, session.Register(127, baseOID))
defer session.Unregister(127, baseOID)
t.Run("Get", func(t *testing.T) {
assert.Equal(t,
".1.3.6.1.4.1.45995.3.1 = STRING: \"test\"",
SNMPGet(t, "1.3.6.1.4.1.45995.3.1"))
assert.Equal(t,
".1.3.6.1.4.1.45995.3.2 = No Such Object available on this agent at this OID",
SNMPGet(t, "1.3.6.1.4.1.45995.3.2"))
})
t.Run("GetNext", func(t *testing.T) {
assert.Equal(t,
".1.3.6.1.4.1.45995.3.1 = STRING: \"test\"",
SNMPGetNext(t, "1.3.6.1.4.1.45995.3.0"))
assert.Equal(t,
".1.3.6.1.4.1.45995.3.1 = STRING: \"test\"",
SNMPGetNext(t, "1.3.6.1.4.1.45995.3"))
})
t.Run("GetBulk", func(t *testing.T) {
assert.Equal(t,
".1.3.6.1.4.1.45995.3.1 = STRING: \"test\"",
SNMPGetBulk(t, "1.3.6.1.4.1.45995.3.0", 0, 1))
})
}