Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Functionality 🚀 #2

Merged
merged 1 commit into from
Sep 8, 2023
Merged

Merge Functionality 🚀 #2

merged 1 commit into from
Sep 8, 2023

Conversation

Otoru
Copy link
Owner

@Otoru Otoru commented Sep 8, 2023

This PR introduces the ability to merge two Zeus containers seamlessly. With the new Merge function, users can combine the factories of one container into another, enhancing modularity and reusability.

Key Features

Merge Functionality

The new Merge function allows users to integrate all factories from one container into another. This is especially useful for projects that have modularized their dependencies and wish to combine them for specific use-cases.

Conflict Resolution

During the merge process, if a factory from the merging container conflicts with an existing factory in the main container, and they aren't identical, a FactoryAlreadyProvidedError is returned. This ensures that users don't accidentally overwrite essential dependencies.

Changes

  1. Added the Merge function to the Zeus container.
  2. Introduced FactoryConflictError to handle factory conflicts during the merge process.
  3. Updated unit tests to validate the behavior of the Merge function.

How to Test

  1. Check out this branch.
  2. Create two Zeus containers and add factories to them.
  3. Use the Merge function to combine the factories of one container into another.
  4. Run go test to validate the new functionality.

Example

containerA := zeus.New()
containerB := zeus.New()

containerA.Provide(func() string { return "Hello" })
containerB.Provide(func() int { return 42 })

err := containerA.Merge(containerB)
if err != nil {
    // Handle merge error
}

Notes

This enhancement is a step forward in making Zeus more flexible and user-friendly. It allows developers to manage their dependencies more effectively, especially in larger projects with multiple modules.

@Otoru Otoru merged commit 5e86e85 into main Sep 8, 2023
1 check passed
@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (41ca1fb) 100.00% compared to head (27ecc12) 100.00%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #2   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          105       114    +9     
=========================================
+ Hits           105       114    +9     
Files Changed Coverage Δ
container.go 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Otoru Otoru deleted the feature/merge branch December 21, 2023 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant