forked from kata-containers/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mockreaper_test.go
87 lines (73 loc) · 1.57 KB
/
mockreaper_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// Copyright (c) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"os/exec"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMockReaperInit(t *testing.T) {
m := &mockreaper{}
m.init()
}
func TestMockReaperGetExitCodeCh(t *testing.T) {
assert := assert.New(t)
m := &mockreaper{}
c, e := m.getExitCodeCh(0)
assert.Nil(c)
assert.NoError(e)
}
func TestMockReaperSetExitCodeCh(t *testing.T) {
m := &mockreaper{}
m.setExitCodeCh(0, nil)
}
func TestMockReaperDeleteExitCodeCh(t *testing.T) {
m := &mockreaper{}
m.deleteExitCodeCh(0)
}
func TestMockReaperReap(t *testing.T) {
assert := assert.New(t)
m := &mockreaper{}
err := m.reap()
assert.NoError(err)
}
func TestMockReaperStart(t *testing.T) {
assert := assert.New(t)
m := &mockreaper{}
c, e := m.start(nil)
assert.Nil(c)
assert.NoError(e)
}
func TestMockReaperWait(t *testing.T) {
assert := assert.New(t)
m := &mockreaper{}
e, err := m.wait(nil, &reaperOSProcess{})
assert.Equal(0, e)
assert.NoError(err)
}
func TestMockReaperLock(t *testing.T) {
m := &mockreaper{}
m.lock()
}
func TestMockReaperUnlock(t *testing.T) {
m := &mockreaper{}
m.unlock()
}
func TestMockReaperRun(t *testing.T) {
assert := assert.New(t)
m := &mockreaper{}
c := exec.Command("echo", "hi")
assert.NoError(m.run(c))
}
func TestMockReaperCombinedOutput(t *testing.T) {
expectedOutput := []byte("hi")
assert := assert.New(t)
m := &mockreaper{}
c := exec.Command("echo", "-n", "hi")
output, err := m.combinedOutput(c)
assert.NoError(err)
assert.Equal(expectedOutput, output)
}