Skip to content

Commit 5acf042

Browse files
committed
Merge branch 'pilip/fix-test-sdk-type' into 'master'
tests: specify a test sdk-type See merge request TankerHQ/sdk-rust!20
2 parents f4ec42c + 3f440c3 commit 5acf042

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/ctanker.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ pub unsafe fn set_log_handler(callback: LogHandlerCallback) {
9090
}
9191

9292
pub async fn create(options: Options) -> Result<CTankerPtr, Error> {
93-
let sdk_type = CString::new(RUST_SDK_TYPE).unwrap();
93+
let sdk_type = options
94+
.sdk_type
95+
.unwrap_or_else(|| CString::new(RUST_SDK_TYPE).unwrap());
9496
let sdk_version = CString::new(RUST_SDK_VERSION).unwrap();
9597
let coptions = tanker_options {
9698
version: 2,

src/types.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub struct Options {
1111
pub(crate) url: Option<CString>,
1212
pub(crate) app_id: CString,
1313
pub(crate) writable_path: CString,
14+
pub(crate) sdk_type: Option<CString>,
1415
}
1516

1617
impl Options {
@@ -23,13 +24,19 @@ impl Options {
2324
url: None,
2425
app_id: CString::new(app_id).unwrap(),
2526
writable_path: CString::new(writable_path).unwrap(),
27+
sdk_type: None,
2628
}
2729
}
2830

2931
pub fn with_url(mut self, url: String) -> Self {
3032
self.url = Some(CString::new(url).unwrap());
3133
self
3234
}
35+
36+
pub fn with_sdk_type(mut self, sdk_type: String) -> Self {
37+
self.sdk_type = Some(CString::new(sdk_type).unwrap());
38+
self
39+
}
3340
}
3441

3542
#[derive(Debug, Clone, Copy, Eq, PartialEq, UnsafeFromPrimitive)]

tests/identity/test_app.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl TestApp {
3939
pub fn make_options(&self) -> Options {
4040
Options::new(self.id().to_owned(), ":memory:".to_owned())
4141
.with_url(self.config.api_url.clone())
42+
.with_sdk_type("sdk-rust-test".to_string())
4243
}
4344

4445
async fn new() -> Self {

tests/tanker_tests.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ fn core_native_version() {
1616
#[tokio::test]
1717
async fn tanker_create() -> Result<(), Error> {
1818
let app = TestApp::get().await;
19-
let opts = Options::new(app.id().to_owned(), ":memory:".to_string());
19+
let opts = Options::new(app.id().to_owned(), ":memory:".to_string())
20+
.with_sdk_type("sdk-rust-test".to_string());
2021
let core = Core::new(opts).await?;
2122
drop(core);
2223
Ok(())
2324
}
2425

2526
#[tokio::test]
2627
async fn tanker_bad_create() {
27-
let opts = Options::new("bad-app-id".to_string(), ":memory:".to_string());
28+
let opts = Options::new("bad-app-id".to_string(), ":memory:".to_string())
29+
.with_sdk_type("sdk-rust-test".to_string());
2830
let err = Core::new(opts)
2931
.await
3032
.expect_err("The app ID should not be accepted, it's not valid base64");

0 commit comments

Comments
 (0)