-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo_unix_test.go
52 lines (47 loc) · 1.25 KB
/
info_unix_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
// +build !windows
package daemon
import (
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/dockerversion"
"github.com/stretchr/testify/assert"
)
func TestParseInitVersion(t *testing.T) {
tests := []struct {
version string
result types.Commit
invalid bool
}{
{
version: "tini version 0.13.0 - git.949e6fa",
result: types.Commit{ID: "949e6fa", Expected: dockerversion.InitCommitID[0:7]},
}, {
version: "tini version 0.13.0\n",
result: types.Commit{ID: "v0.13.0", Expected: dockerversion.InitCommitID},
}, {
version: "tini version 0.13.2",
result: types.Commit{ID: "v0.13.2", Expected: dockerversion.InitCommitID},
}, {
version: "tini version0.13.2",
result: types.Commit{ID: "N/A", Expected: dockerversion.InitCommitID},
invalid: true,
}, {
version: "",
result: types.Commit{ID: "N/A", Expected: dockerversion.InitCommitID},
invalid: true,
}, {
version: "hello world",
result: types.Commit{ID: "N/A", Expected: dockerversion.InitCommitID},
invalid: true,
},
}
for _, test := range tests {
ver, err := parseInitVersion(string(test.version))
if test.invalid {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
assert.Equal(t, test.result, ver)
}
}