This repository has been archived by the owner on Jun 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
117 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,96 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Facter::Resolvers::OsRelease do | ||
before do | ||
allow(File).to receive(:readable?) | ||
.with('/etc/os-release') | ||
.and_return(true) | ||
context 'when os is ubuntu' do | ||
before do | ||
allow(File).to receive(:readable?) | ||
.with('/etc/os-release') | ||
.and_return(true) | ||
|
||
allow(File).to receive(:read) | ||
.with('/etc/os-release') | ||
.and_return(load_fixture('os_release').read) | ||
allow(File).to receive(:read) | ||
.with('/etc/os-release') | ||
.and_return(load_fixture('os_release').read) | ||
end | ||
|
||
Facter::Resolvers::OsRelease.invalidate_cache | ||
end | ||
after do | ||
Facter::Resolvers::OsRelease.invalidate_cache | ||
end | ||
|
||
it 'returns os NAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:name) | ||
it 'returns os NAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:name) | ||
|
||
expect(result).to eq('Ubuntu') | ||
end | ||
expect(result).to eq('Ubuntu') | ||
end | ||
|
||
it 'returns os PRETTY_NAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:pretty_name) | ||
it 'returns os PRETTY_NAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:pretty_name) | ||
|
||
expect(result).to eq('Ubuntu 18.04.1 LTS') | ||
end | ||
expect(result).to eq('Ubuntu 18.04.1 LTS') | ||
end | ||
|
||
it 'returns os VERSION_ID' do | ||
result = Facter::Resolvers::OsRelease.resolve(:version_id) | ||
|
||
expect(result).to eq('18.04') | ||
end | ||
|
||
it 'returns os VERSION_ID' do | ||
result = Facter::Resolvers::OsRelease.resolve(:version_id) | ||
it 'returns os release' do | ||
result = Facter::Resolvers::OsRelease.resolve(:release) | ||
|
||
expect(result).to eq('18.04') | ||
expect(result).to eq('18.04') | ||
end | ||
|
||
it 'returns os VERSION_CODENAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:version_codename) | ||
|
||
expect(result).to eq('bionic') | ||
end | ||
end | ||
|
||
it 'returns os VERSION_CODENAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:version_codename) | ||
context 'when os is Debian' do | ||
before do | ||
allow(File).to receive(:readable?).with('/etc/os-release').and_return(true) | ||
|
||
allow(File).to receive(:read) | ||
.with('/etc/os-release') | ||
.and_return(load_fixture('os_release_debian').read) | ||
|
||
allow(File).to receive(:readable?).with('/etc/debian_version').and_return(true) | ||
allow(File).to receive(:read).with('/etc/debian_version').and_return("10.0\n") | ||
end | ||
|
||
after do | ||
Facter::Resolvers::OsRelease.invalidate_cache | ||
end | ||
|
||
it 'returns os release' do | ||
result = Facter::Resolvers::OsRelease.resolve(:release) | ||
|
||
expect(result).to eq('10.0') | ||
end | ||
|
||
it 'returns os NAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:name) | ||
|
||
expect(result).to eq('Debian') | ||
end | ||
|
||
it 'returns os PRETTY_NAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:pretty_name) | ||
|
||
expect(result).to eq('Debian GNU/Linux 10 (buster)') | ||
end | ||
|
||
it 'returns os VERSION_ID' do | ||
result = Facter::Resolvers::OsRelease.resolve(:version_id) | ||
|
||
expect(result).to eq('10') | ||
end | ||
|
||
it 'returns os VERSION_CODENAME' do | ||
result = Facter::Resolvers::OsRelease.resolve(:version_codename) | ||
|
||
expect(result).to eq('bionic') | ||
expect(result).to eq('buster') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
PRETTY_NAME="Debian GNU/Linux 10 (buster)" | ||
NAME="Debian GNU/Linux" | ||
VERSION_ID="10" | ||
VERSION="10 (buster)" | ||
VERSION_CODENAME=buster | ||
ID=debian | ||
HOME_URL="https://www.debian.org/" | ||
SUPPORT_URL="https://www.debian.org/support" | ||
BUG_REPORT_URL="https://bugs.debian.org/" |