Parse runtime name

Signed-off-by: Carlos de Paula <me@carlosedp.com>
This commit is contained in:
Carlos de Paula
2019-09-15 11:15:27 -04:00
parent 4ab1e808d1
commit 1a96cf95ca
2 changed files with 14 additions and 8 deletions

View File

@@ -50,9 +50,10 @@ func TestParseInitVersion(t *testing.T) {
}
}
func TestParseRuncVersion(t *testing.T) {
func parseRuncVersion(t *testing.T) {
tests := []struct {
output string
runtime string
version string
commit string
invalid bool
@@ -63,6 +64,7 @@ runc version 1.0.0-rc5+dev
commit: 69663f0bd4b60df09991c08812a60108003fa340
spec: 1.0.0
`,
runtime: "runc",
version: "1.0.0-rc5+dev",
commit: "69663f0bd4b60df09991c08812a60108003fa340",
},
@@ -71,6 +73,7 @@ spec: 1.0.0
runc version 1.0.0-rc5+dev
spec: 1.0.0
`,
runtime: "runc",
version: "1.0.0-rc5+dev",
},
{
@@ -86,6 +89,7 @@ crun version 0.7
spec: 1.0.0
+SYSTEMD +SELINUX +CAP +SECCOMP +EBPF +YAJL
`,
runtime: "crun",
version: "0.7",
},
{
@@ -99,12 +103,13 @@ spec: 1.0.0
}
for _, test := range tests {
version, commit, err := parseRuncVersion(string(test.output))
runtime, version, commit, err := parseRuntimeVersion(string(test.output))
if test.invalid {
assert.Check(t, is.ErrorContains(err, ""))
} else {
assert.Check(t, err)
}
assert.Equal(t, test.runtime, runtime)
assert.Equal(t, test.version, version)
assert.Equal(t, test.commit, commit)
}