-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor_test.go
More file actions
47 lines (44 loc) · 996 Bytes
/
processor_test.go
File metadata and controls
47 lines (44 loc) · 996 Bytes
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
package processor_test
import (
"errors"
"github.com/rady-io/annotation-processor"
"github.com/stretchr/testify/assert"
"testing"
)
func TestProcessor_Scan(t *testing.T) {
i := 0
err := processor.NewProcessor(`
//
@Page(name) {name}
@Body json
@File(avatar)
@Deprecated
@NeverBeHere
`).Scan(func(ann, key, value string) (err error) {
i++
count := i
switch count {
case 1:
assert.Equal(t, "@Page", ann)
assert.Equal(t, "name", key)
assert.Equal(t, "{name}", value)
case 2:
assert.Equal(t, "@Body", ann)
assert.Equal(t, "", key)
assert.Equal(t, "json", value)
case 3:
assert.Equal(t, "@File", ann)
assert.Equal(t, "avatar", key)
assert.Equal(t, "", value)
case 4:
assert.Equal(t, "@Deprecated", ann)
assert.Equal(t, "", key)
assert.Equal(t, "", value)
err = errors.New("Unsupported annotation: " + ann)
}
return
})
assert.Error(t, err)
assert.Equal(t, "Unsupported annotation: @Deprecated", err.Error())
assert.Equal(t, 4, i)
}