Skip to content

Commit

Permalink
Migrating to test-r, work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo committed Oct 10, 2024
1 parent 449164b commit aaf72d7
Show file tree
Hide file tree
Showing 98 changed files with 926 additions and 541 deletions.
97 changes: 96 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ testcontainers-modules = { version = "0.3.2", features = [
"redis",
"minio",
] }
test-r = "0.0.6"
thiserror = "1.0.56"
tokio = { version = "1.0", features = [
"macros",
Expand Down
4 changes: 4 additions & 0 deletions golem-api-grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repository = "https://github.com/golemcloud/golem"
description = "GRPC API for Golem services"

[lib]
harness = false

[dependencies]
async-trait = { workspace = true }
Expand All @@ -24,6 +25,9 @@ tonic = { workspace = true }
tracing = { workspace = true }
uuid = { workspace = true }

[dev-dependencies]
test-r = { workspace = true }

[build-dependencies]
cargo_metadata = "0.18.1"
tonic-build = "0.11.0"
5 changes: 5 additions & 0 deletions golem-api-grpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(test)]
test_r::enable!();

#[allow(clippy::large_enum_variant)]
pub mod proto {
use crate::proto::golem::worker::UpdateMode;
Expand Down Expand Up @@ -215,6 +218,8 @@ pub mod proto {

#[cfg(test)]
mod tests {
use test_r::test;

use crate::proto::golem;
use prost::Message;
use std::str::FromStr;
Expand Down
3 changes: 2 additions & 1 deletion golem-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Shared code between Golem services"


[lib]

harness = false

[dependencies]
golem-api-grpc = { path = "../golem-api-grpc", version = "0.0.0" }
Expand Down Expand Up @@ -54,4 +54,5 @@ wasm-wave = { workspace = true }
itertools = { workspace = true }

[dev-dependencies]
test-r = { workspace = true }
tracing-test = { workspace = true }
3 changes: 3 additions & 0 deletions golem-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub mod serialization;
pub mod tracing;
pub mod uri;

#[cfg(test)]
test_r::enable!();

/// Trait to convert a value to a string which is safe to return through a public API.
pub trait SafeDisplay {
fn to_safe_string(&self) -> String;
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2470,6 +2470,8 @@ impl FromStr for ComponentType {

#[cfg(test)]
mod tests {
use test_r::test;

use std::collections::HashSet;
use std::str::FromStr;
use std::time::SystemTime;
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/model/regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ impl Display for DeletedRegions {

#[cfg(test)]
mod tests {
use test_r::test;

use crate::model::oplog::OplogIndex;
use crate::model::regions::{DeletedRegionsBuilder, OplogRegion};

Expand Down
3 changes: 2 additions & 1 deletion golem-common/src/retries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ where

#[cfg(test)]
mod tests {
use std::time::Duration;
use test_r::test;

use crate::config::RetryConfig;
use std::time::Duration;

#[test]
pub fn get_delay_example_without_jitter() {
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pub fn try_deserialize_with_version<T: Decode>(

#[cfg(test)]
mod tests {
use test_r::test;

use bincode::{Decode, Encode};
use rand::distributions::Alphanumeric;
use rand::Rng;
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ mod test {
}

mod json_flatten_span_formatter {
use test_r::test;

use tracing;
use tracing::{field, info, span, Level};
use tracing_subscriber::FmtSubscriber;
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/uri/cloud/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ uri_from_into!(ResourceUri);

#[cfg(test)]
mod tests {
use test_r::test;

use crate::model::{ComponentId, TargetWorkerId, WorkerId};
use crate::uri::cloud::uri::{
ApiDefinitionUri, ApiDeploymentUri, ComponentOrVersionUri, ComponentUri,
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/uri/cloud/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ impl Display for ResourceUrl {

#[cfg(test)]
mod tests {
use test_r::test;

use crate::uri::cloud::url::{
AccountUrl, ApiDefinitionUrl, ApiDeploymentUrl, ComponentOrVersionUrl, ComponentUrl,
ComponentVersionUrl, ProjectUrl, ResourceUrl, WorkerFunctionUrl, WorkerOrFunctionUrl,
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/uri/cloud/urn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ impl Display for ResourceUrn {

#[cfg(test)]
mod tests {
use test_r::test;

use crate::model::{AccountId, ProjectId};
use crate::uri::cloud::urn::{AccountUrn, ProjectUrn, ResourceUrn};
use crate::uri::GolemUrn;
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,8 @@ impl<'de> Deserialize<'de> for GolemUrl {

#[cfg(test)]
mod tests {
use test_r::test;

use crate::uri::{GolemUri, GolemUrl, GolemUrn};
use std::str::FromStr;
use url::Url;
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/uri/oss/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ uri_from_into!(ResourceUri);

#[cfg(test)]
mod tests {
use test_r::test;

use crate::model::{ComponentId, TargetWorkerId, WorkerId};
use crate::uri::oss::uri::{
ApiDefinitionUri, ApiDeploymentUri, ComponentOrVersionUri, ComponentUri,
Expand Down
2 changes: 2 additions & 0 deletions golem-common/src/uri/oss/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ impl Display for ResourceUrl {

#[cfg(test)]
mod tests {
use test_r::test;

use crate::uri::oss::url::{
ApiDefinitionUrl, ApiDeploymentUrl, ComponentOrVersionUrl, ComponentUrl,
ComponentVersionUrl, ResourceUrl, WorkerFunctionUrl, WorkerOrFunctionUrl, WorkerUrl,
Expand Down
Loading

0 comments on commit aaf72d7

Please sign in to comment.