From 711973e03eb006f7fc35e14ee88aef67ea8403b0 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sun, 22 Dec 2024 20:43:15 -0500 Subject: [PATCH] some non actual test --- src/proto/fixtures/address.proto | 22 ++++++++++++++++++++++ src/proto/fixtures/user.proto | 23 +++++++++++++++++++++++ src/proto/proto.rs | 15 +++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/proto/fixtures/address.proto create mode 100644 src/proto/fixtures/user.proto diff --git a/src/proto/fixtures/address.proto b/src/proto/fixtures/address.proto new file mode 100644 index 0000000..39c5a24 --- /dev/null +++ b/src/proto/fixtures/address.proto @@ -0,0 +1,22 @@ +// address.proto + +syntax = "proto3"; + +package address; + +// Import the user.proto file to use User message +import "user.proto"; + +message Address { + string street = 1; + string city = 2; + string zip_code = 3; + // This field references the User message from user.proto + user.User user = 4; // Here we reference the User message +} + +// Define the AddressService service +service AddressService { + rpc AddAddress (Address) returns (Address); + rpc GetAddressForUser (user.User) returns (Address); +} diff --git a/src/proto/fixtures/user.proto b/src/proto/fixtures/user.proto new file mode 100644 index 0000000..91ad67f --- /dev/null +++ b/src/proto/fixtures/user.proto @@ -0,0 +1,23 @@ +// user.proto + +syntax = "proto3"; + +package user; + +// Define the User message +message User { + string id = 1; + string name = 2; + string email = 3; +} + +// Define the GetUserRequest message +message GetUserRequest { + string id = 1; +} + +// Define the UserService service +service UserService { + rpc GetUser (GetUserRequest) returns (User); + rpc CreateUser (User) returns (User); +} diff --git a/src/proto/proto.rs b/src/proto/proto.rs index 00e9b85..6b8823c 100644 --- a/src/proto/proto.rs +++ b/src/proto/proto.rs @@ -49,4 +49,19 @@ mod t { resolve.push_str("foox.wit", &config.to_wit()).expect("TODO: panic message`"); println!("{:#?}", resolve); } + + #[test] + fn bar() { + let relative = format!("{}/src/proto/fixtures",env!("CARGO_MANIFEST_DIR")); + let x = std::fs::read_to_string(format!("{}/address.proto", relative)).unwrap(); + let proto = protox::compile([format!("{}/address.proto", relative)], [relative]).unwrap(); + let proto = Proto::new([proto]); + let config = proto.to_config().to_result().unwrap(); + println!("{}", config.to_wit()); + // print!("{:#?}", config); + + let mut resolve = Resolve::new(); + resolve.push_str("foox.wit", &config.to_wit()).expect("TODO: panic message`"); + println!("{:#?}", resolve); + } } \ No newline at end of file