Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Set up temporary repository only once
Browse files Browse the repository at this point in the history
  • Loading branch information
floriandejonckheere committed Mar 31, 2024
1 parent e9f4d96 commit d86a377
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 106 deletions.
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--color
--require spec_helper
--tag ~repository
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ The `evaluate` command analyzes the given microservices architecture, and evalua
```bash
$ mosaik evaluate --help
```
## Development and Testing

Some test make use of a simulated git repository. If you want to use this repository for development, run the following command:

```bash
$ rspec spec/mosaik/repository_spec.rb --tag repository
```

The simulated git repository will be copied to `tmp/repository` and can be used for development.

## Releasing

Expand Down
8 changes: 2 additions & 6 deletions spec/mosaik/extractors/evolution_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
end

describe "logical coupling" do
let(:options) { { directory:, limit: 100, logical: 1, contributor: 0 } }

include_context "with a git repository"
let(:options) { { directory: "tmp/repository", limit: 100, logical: 1, contributor: 0 } }

it "constructs a logical coupling graph" do
extractor.call
Expand All @@ -48,9 +46,7 @@
end

describe "contributor coupling" do
let(:options) { { directory:, limit: 100, logical: 0, contributor: 1 } }

include_context "with a git repository"
let(:options) { { directory: "tmp/repository", limit: 100, logical: 0, contributor: 1 } }

it "constructs a contributor coupling graph" do
extractor.call
Expand Down
2 changes: 0 additions & 2 deletions spec/mosaik/extractors/structural_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
describe "structural coupling" do
let(:options) { { structural: 1 } }

include_context "with a git repository"

it "constructs a logical coupling graph" do
extractor.call

Expand Down
11 changes: 0 additions & 11 deletions spec/mosaik/repository_spec.rb

This file was deleted.

79 changes: 79 additions & 0 deletions spec/support/setup_repository.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# frozen_string_literal: true

# Relative path to the repository
DIRECTORY = "tmp/repository"

# Committers
john = "John Doe <[email protected]>"
jane = "Jane Doe <[email protected]>"
joey = "Joey Doe <[email protected]>"

# Cleanup the temporary repository directory
FileUtils.remove_entry(DIRECTORY)

# Initialize the repository
GIT = Git.init(DIRECTORY)

# Set up committer configuration
GIT.config("user.name", "John Doe")
GIT.config("user.email", "[email protected]")

def commit(author, **files_with_content)
# Write the files with content
files_with_content.each do |file, content|
FileUtils.mkdir_p(File.join(DIRECTORY, File.dirname(file)))
File.write(File.join(DIRECTORY, file), content)
end

# Add and commit the files
GIT.add
GIT.commit("Add #{files_with_content.keys.join(', ')}", author:)
end

# Setup the repository with initial commit
commit john,
"README.md" => "# Test Repository"

# Add MOSAIK configuration
commit john,
"mosaik.yml" => File.read(MOSAIK.root.join("config/mosaik.yml"))

# Add application structure
commit john,
"lib/app.rb" => "class App; end"

# Add classes
commit john,
"lib/app/foo.rb" => "class App::Foo; end",
"lib/app/bar.rb" => "class App::Bar; end"

commit jane,
"lib/app/foo.rb" => "class App::Foo; def initialize; end; end",
"lib/app/bat.rb" => "class App::Bat; end"

commit john,
"lib/app/foo.rb" => "class App::Foo; end",
"lib/app/bak.rb" => "class App::Bak; end"

commit jane,
"lib/app/bat.rb" => "class App::Bat; def initialize; end; end",
"lib/app/baz.rb" => "class App::Baz; end"

commit john,
"lib/app/bat.rb" => "class App::Bat; end",
"lib/app/baz.rb" => "class App::Baz; def initialize; end; end"

commit joey,
"lib/app/bat.rb" => "class App::Bat; def initialize; end; end",
"lib/app/baz.rb" => "class App::Baz; end"

RSpec.configure do |config|
config.before do
configuration = MOSAIK::Configuration.from(File.join(DIRECTORY, "mosaik.yml"))

# Mock the configuration
allow(MOSAIK)
.to receive(:configuration)
.and_return configuration
end
end
77 changes: 0 additions & 77 deletions spec/support/shared_contexts/repository.rb

This file was deleted.

0 comments on commit d86a377

Please sign in to comment.