mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-14 23:43:56 +01:00
tests(aa-log): add missing tests for osrelease.
This commit is contained in:
parent
ae9f7e7442
commit
58f130fbb2
@ -18,7 +18,7 @@ var (
|
||||
"arch": {},
|
||||
"debian": {},
|
||||
"ubuntu": {},
|
||||
"opensuse": {"suse"},
|
||||
"opensuse": {"suse", "opensuse-tumbleweed"},
|
||||
"whonix": {},
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
package prebuild
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/arduino/go-paths-helper"
|
||||
@ -78,6 +79,63 @@ ANSI_COLOR="0;38;2;60;110;180"
|
||||
LOGO=fedora-logo-icon`
|
||||
)
|
||||
|
||||
func TestNewOSRelease(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
osRelease string
|
||||
want map[string]string
|
||||
}{
|
||||
{
|
||||
name: "Archlinux",
|
||||
osRelease: Archlinux,
|
||||
want: map[string]string{
|
||||
"NAME": "Arch Linux",
|
||||
"PRETTY_NAME": "Arch Linux",
|
||||
"ID": "arch",
|
||||
"BUILD_ID": "rolling",
|
||||
"ANSI_COLOR": "38;2;23;147;209",
|
||||
"HOME_URL": "https://archlinux.org/",
|
||||
"DOCUMENTATION_URL": "https://wiki.archlinux.org/",
|
||||
"SUPPORT_URL": "https://bbs.archlinux.org/",
|
||||
"BUG_REPORT_URL": "https://bugs.archlinux.org/",
|
||||
"PRIVACY_POLICY_URL": "https://terms.archlinux.org/docs/privacy-policy/",
|
||||
"LOGO": "archlinux-logo",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Ubuntu",
|
||||
osRelease: Ubuntu,
|
||||
want: map[string]string{
|
||||
"PRETTY_NAME": "Ubuntu 22.04.2 LTS",
|
||||
"NAME": "Ubuntu",
|
||||
"VERSION_ID": "22.04",
|
||||
"VERSION": "22.04.2 LTS (Jammy Jellyfish)",
|
||||
"VERSION_CODENAME": "jammy",
|
||||
"ID": "ubuntu",
|
||||
"ID_LIKE": "debian",
|
||||
"HOME_URL": "https://www.ubuntu.com/",
|
||||
"SUPPORT_URL": "https://help.ubuntu.com/",
|
||||
"BUG_REPORT_URL": "https://bugs.launchpad.net/ubuntu/",
|
||||
"PRIVACY_POLICY_URL": "https://www.ubuntu.com/legal/terms-and-policies/privacy-policy",
|
||||
"UBUNTU_CODENAME": "jammy",
|
||||
},
|
||||
},
|
||||
}
|
||||
osReleaseFile = "/tmp/os-release"
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := paths.New(osReleaseFile).WriteFile([]byte(tt.osRelease))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if got := NewOSRelease(); !reflect.DeepEqual(got, tt.want) {
|
||||
pp.Print(got)
|
||||
t.Errorf("NewOSRelease() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_getSupportedDistribution(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
Loading…
Reference in New Issue
Block a user