Fix Amazon Linux 2 scanning (#630)

* fix(amazon2): fix OS version parse error
This commit is contained in:
Kota Kanbe
2018-04-10 11:53:11 +09:00
committed by GitHub
parent ce56261b52
commit 5076326589
2 changed files with 47 additions and 0 deletions

View File

@@ -62,3 +62,42 @@ func TestSyslogConfValidate(t *testing.T) {
}
}
}
func TestMajorVersion(t *testing.T) {
var tests = []struct {
in Distro
out int
}{
{
in: Distro{
Family: Amazon,
Release: "2 (2017.12)",
},
out: 2,
},
{
in: Distro{
Family: Amazon,
Release: "2017.12",
},
out: 1,
},
{
in: Distro{
Family: CentOS,
Release: "7.10",
},
out: 7,
},
}
for i, tt := range tests {
ver, err := tt.in.MajorVersion()
if err != nil {
t.Errorf("[%d] err occurred: %s", i, err)
}
if tt.out != ver {
t.Errorf("[%d] expected %d, actual %d", i, tt.out, ver)
}
}
}