forked from Shanghai-Lunara/date-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_test.go
More file actions
41 lines (39 loc) · 756 Bytes
/
time_test.go
File metadata and controls
41 lines (39 loc) · 756 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
package date_agent
import (
"fmt"
"testing"
)
func TestExec(t *testing.T) {
hostname, err := GetHostName()
if err != nil {
t.Errorf(err.Error())
}
type args struct {
commands []string
}
tests := []struct {
name string
args args
wantOut string
wantErr bool
}{
{
name: "case_1",
args: args{commands: []string{"hostname"}},
wantOut: fmt.Sprintf("%s\n", hostname),
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotOut, err := Exec(tt.args.commands)
if (err != nil) != tt.wantErr {
t.Errorf("Exec() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotOut != tt.wantOut {
t.Errorf("Exec() = %v, want %v", gotOut, tt.wantOut)
}
})
}
}