-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.tmpl
94 lines (80 loc) · 3.18 KB
/
handler.tmpl
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (C) 2020-2022 Red Hat, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
package {{ .LowerHandlername }}
import (
"time"
"github.com/test-network-function/test-network-function/pkg/tnf"
"github.com/test-network-function/test-network-function/pkg/tnf/identifier"
"github.com/test-network-function/test-network-function/pkg/tnf/reel"
)
// {{ .UpperHandlername }} is the reel handler struct.
type {{ .UpperHandlername }} struct {
result int
timeout time.Duration
args []string
// adding special parameters
}
const (
// adding special variables
)
// New{{ .UpperHandlername }} returns a new {{ .UpperHandlername }} handler struct.
// TODO: Add needed parameters to this function and initialize the handler properly.
func New{{ .UpperHandlername }}(timeout time.Duration) *{{ .UpperHandlername }} {
return &{{ .UpperHandlername }}{
timeout: timeout,
result: tnf.ERROR,
args: []string{}, // TODO: Add proper execution command.
}
}
// Args returns the initial execution/send command strings for handler {{ .UpperHandlername }}.
func (h *{{ .UpperHandlername }}) Args() []string {
return h.args
}
// GetIdentifier returns the tnf.Test specific identifier.
func (h *{{ .UpperHandlername }}) GetIdentifier() identifier.Identifier {
// Return the {{ .UpperHandlername }} handler identifier.
return identifier.Identifier{}
}
// Timeout returns the timeout for the test.
func (h *{{ .UpperHandlername }}) Timeout() time.Duration {
return h.timeout
}
// Result returns the test result.
func (h *{{ .UpperHandlername }}) Result() int {
return h.result
}
// ReelFirst returns a reel step for handler {{ .UpperHandlername }}.
func (h *{{ .UpperHandlername }}) ReelFirst() *reel.Step {
return &reel.Step{
Expect: []string{}, // TODO : pass the list of possible regex in here
Timeout: h.timeout,
}
}
// ReelMatch parses the {{ .UpperHandlername }} output and set the test result on match.
func (h *{{ .UpperHandlername }}) ReelMatch(_, _, match string) *reel.Step {
// TODO : add the matching logic here and return an appropriate tnf result.
h.result = tnf.ERROR
return nil
}
// ReelTimeout function for {{ .UpperHandlername }} will be called by the reel FSM when a expect timeout occurs.
func (h *{{ .UpperHandlername }}) ReelTimeout() *reel.Step {
// TODO : Add code here in case a timeout reaction is needed.
return nil
}
// ReelEOF function for {{ .UpperHandlername }} will be called by the reel FSM when a EOF is read.
func (h *{{ .UpperHandlername }}) ReelEOF() {
// TODO : Add code here in case a EOF reaction is needed.
}