Skip to content

Commit d5cb446

Browse files
committed
add an unit test for parsing the "/etc/os-release" of CentOS
add a newline character at the end
1 parent 9b9f18a commit d5cb446

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

pkg/util/helpers_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ func TestGetOSVersion(t *testing.T) {
161161
expectedOSVersion: "ubuntu 16.04.6 LTS (Xenial Xerus)",
162162
expectErr: false,
163163
},
164+
{
165+
name: "centos",
166+
fakeOSReleasePath: "testdata/os-release-centos",
167+
expectedOSVersion: "centos 7 (Core)",
168+
expectErr: false,
169+
},
164170
{
165171
name: "Unknown",
166172
fakeOSReleasePath: "testdata/os-release-unknown",

pkg/util/testdata/os-release-centos

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
NAME="CentOS Linux"
2+
VERSION="7 (Core)"
3+
ID="centos"
4+
ID_LIKE="rhel fedora"
5+
VERSION_ID="7"
6+
PRETTY_NAME="CentOS Linux 7 (Core)"
7+
ANSI_COLOR="0;31"
8+
CPE_NAME="cpe:/o:centos:centos:7"
9+
HOME_URL="https://www.centos.org/"
10+
BUG_REPORT_URL="https://bugs.centos.org/"
11+
12+
CENTOS_MANTISBT_PROJECT="CentOS-7"
13+
CENTOS_MANTISBT_PROJECT_VERSION="7"
14+
REDHAT_SUPPORT_PRODUCT="centos"
15+
REDHAT_SUPPORT_PRODUCT_VERSION="7"

0 commit comments

Comments
 (0)