-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextends_test.go
52 lines (39 loc) · 878 Bytes
/
extends_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
package rfc8288
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestExtends(t *testing.T) {
assert := assert.New(t)
// should make the value accessible via Extension(key)"
// given
l := Link{}
key := "extension"
value := "value"
// when
l.Extend(key, value)
result, ok := l.Extension(key)
// then
assert.True(ok)
assert.Equal(value, result)
// should delete the extension if assigned a nil value"
// given
l = Link{}
key = "extension"
value = "value"
// when
l.Extend(key, value)
l.Extend(key, nil)
result, ok = l.Extension(key)
// then
assert.False(ok)
assert.Nil(result)
// should return ErrExtensionKeyIsReserved if attempting to Extend with reserved key"
// given
l = Link{}
// expect
for reservedKey := range ReservedKeys {
err := l.Extend(reservedKey, "any")
assert.Equal(ErrExtensionKeyIsReserved, err)
}
}