Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests for Store, LinkageStore, Database, and LinkageDatabase.
- Loading branch information
1 parent
8fafc4d
commit 4523a49
Showing
6 changed files
with
142 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "os/mac/database/database" | ||
|
||
describe Database do | ||
subject { Database.new("test") } | ||
|
||
describe "#initialize" do | ||
it "should raise error trying to initialize" do | ||
expect { Database.new("test") } | ||
.to raise_error(NotImplementedError) | ||
end | ||
end | ||
|
||
describe "#create_tables" do | ||
it "should be abstract" do | ||
expect { subject.create_tables } | ||
.to raise_error(NotImplementedError) | ||
end | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
Library/Homebrew/test/os/mac/database/linkage_database_spec.rb
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,12 @@ | ||
require "os/mac/database/linkage_database" | ||
|
||
describe LinkageDatabase do | ||
subject { LinkageDatabase.new } | ||
|
||
describe "#create_tables" do | ||
it "should be concrete" do | ||
expect { subject.create_tables } | ||
.to_not raise_error(NotImplementedError) | ||
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,72 @@ | ||
require "os/mac/store/linkage_store" | ||
require "os/mac/database/helpers/linkage_database_types" | ||
|
||
describe LinkageStore do | ||
include LinkageDatabaseTypes | ||
|
||
subject { LinkageStore.new("scala") } | ||
|
||
describe "#update!" do | ||
it "should be concrete" do | ||
expect { subject.update!(path_values: {}, hash_values: {}) } | ||
.to_not raise_error(NotImplementedError) | ||
end | ||
end | ||
|
||
describe "#fetch" do | ||
describe "HASH_LINKAGE_TYPES" do | ||
let(:type) { LinkageDatabaseTypes::HASH_LINKAGE_TYPES.sample } | ||
|
||
it "should fetch hash values for a HASH_LINKAGE_TYPE" do | ||
expect(subject) | ||
.to receive(:fetch_hash_values).with(type: type) | ||
|
||
subject.fetch(type: type) | ||
end | ||
end | ||
|
||
describe "GENERALIZED_TYPES" do | ||
let(:type) { LinkageDatabaseTypes::GENERALIZED_TYPES.sample } | ||
|
||
it "should fetch path values for a GENERALIZED_TYPE" do | ||
expect(subject) | ||
.to receive(:fetch_path_values).with(type: type) | ||
|
||
subject.fetch(type: type) | ||
end | ||
end | ||
|
||
it "should be concrete" do | ||
expect { subject.fetch(type: nil) } | ||
.to_not raise_error(NotImplementedError) | ||
end | ||
end | ||
|
||
describe "#flush_condition" do | ||
it "should be concrete" do | ||
expect { subject.flush_condition } | ||
.to_not raise_error(NotImplementedError) | ||
end | ||
|
||
it "should return `name = '<key>'`" do | ||
subject.stub(:key) { "scala" } | ||
expect(subject.flush_condition).to eq("name = 'scala'") | ||
end | ||
end | ||
|
||
describe "#flush_cache!" do | ||
it "should be concrete" do | ||
expect { subject.flush_cache! } | ||
.to_not raise_error(NotImplementedError) | ||
end | ||
|
||
it "should call flush condition" do | ||
subject.stub(:flush_condition) { "name = 'scala'" } | ||
|
||
expect(subject) | ||
.to receive(:flush_condition) | ||
|
||
subject.flush_cache! | ||
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,33 @@ | ||
require "os/mac/store/store" | ||
|
||
describe Store do | ||
subject { Store.new(double("Fake database", db: "db", name: "name")) } | ||
|
||
describe "#update!" do | ||
it "should be abstract" do | ||
expect { subject.update!(nil) } | ||
.to raise_error(NotImplementedError) | ||
end | ||
end | ||
|
||
describe "#fetch" do | ||
it "should be abstract" do | ||
expect { subject.fetch(nil) } | ||
.to raise_error(NotImplementedError) | ||
end | ||
end | ||
|
||
describe "#flush_condition" do | ||
it "should be abstract" do | ||
expect { subject.flush_condition } | ||
.to raise_error(NotImplementedError) | ||
end | ||
end | ||
|
||
describe "#flush_cache!" do | ||
it "should be abstract" do | ||
expect { subject.flush_cache! } | ||
.to raise_error(NotImplementedError) | ||
end | ||
end | ||
end |