generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the namespace validation for oracle metrics
- Loading branch information
1 parent
41d9626
commit ba1ff9c
Showing
3 changed files
with
59 additions
and
2 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
45 changes: 45 additions & 0 deletions
45
.../io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudNamespaceValidationSpec.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,45 @@ | ||
package io.micronaut.oraclecloud.monitoring.micrometer | ||
|
||
import io.micronaut.context.ApplicationContext | ||
import jakarta.inject.Inject | ||
import spock.lang.Specification | ||
|
||
class OracleCloudNamespaceValidationSpec extends Specification { | ||
|
||
@Inject | ||
ApplicationContext context | ||
|
||
def "test valid namespaces"() { | ||
given: | ||
var pattern = OracleCloudConfig.NAMESPACE_PATTERN | ||
|
||
expect: | ||
pattern.matcher(string).matches() | ||
|
||
where: | ||
string | _ | ||
"namespace" | _ | ||
"namespace123" | _ | ||
"my_space_123" | _ | ||
"example_namespace" | _ | ||
} | ||
|
||
def "test invalid namespaces"() { | ||
given: | ||
var pattern = OracleCloudConfig.NAMESPACE_PATTERN | ||
|
||
expect: | ||
!pattern.matcher(string).matches() | ||
|
||
where: | ||
string | _ | ||
"one&two" | _ | ||
"-namespace" | _ | ||
"Namespace%Example" | _ | ||
"123-my-space" | _ | ||
"NAMESPACE" | _ | ||
"example-namespace" | _ | ||
"EXAMPLE-Namespace-example123" | _ | ||
"my-space-123" | _ | ||
} | ||
} |