generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make LocalStorageOperations the primary bean (#314)
- Loading branch information
1 parent
b74ce4c
commit 4d1e229
Showing
4 changed files
with
51 additions
and
0 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
46 changes: 46 additions & 0 deletions
46
...age-local/src/test/groovy/io/micronaut/objectstorage/local/LocalStoragePrimarySpec.groovy
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,46 @@ | ||
package io.micronaut.objectstorage.local | ||
|
||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.context.annotation.Factory | ||
import io.micronaut.context.annotation.Property | ||
import io.micronaut.context.annotation.Requires | ||
import io.micronaut.objectstorage.ObjectStorageOperations | ||
import io.micronaut.test.annotation.MockBean | ||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import software.amazon.awssdk.services.s3.S3Client | ||
import spock.lang.Specification | ||
|
||
@Property(name = "spec.name", value = SPEC_NAME) | ||
@Property(name = "micronaut.object-storage.local.default.enabled", value = "true") | ||
@Property(name = "micronaut.object-storage.aws.default.enabled", value = "true") | ||
@MicronautTest | ||
class LocalStoragePrimarySpec extends Specification { | ||
|
||
public static final String SPEC_NAME = 'LocalStoragePrimarySpec' | ||
|
||
@Inject | ||
ApplicationContext ctx | ||
|
||
void "both local and aws storage are enabled"() { | ||
when: | ||
def beans = ctx.getBeansOfType(ObjectStorageOperations) | ||
|
||
then: | ||
beans.size() == 2 | ||
} | ||
|
||
void "local storage is primary"() { | ||
when: | ||
def operations = ctx.getBean(ObjectStorageOperations) | ||
|
||
then: | ||
operations instanceof LocalStorageOperations | ||
} | ||
|
||
@MockBean(S3Client) | ||
S3Client s3Client() { | ||
return Mock(S3Client) | ||
} | ||
|
||
} |
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