Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncomment device detection toml test #348

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 58 additions & 58 deletions cli/tests/integration/device_detection_lookup.rs
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
// use crate::common::{Test, TestResult};
// use hyper::{body::to_bytes, StatusCode};
use crate::common::{Test, TestResult};
use hyper::{body::to_bytes, StatusCode};

// #[tokio::test(flavor = "multi_thread")]
// async fn json_device_detection_lookup_works() -> TestResult {
// const FASTLY_TOML: &str = r#"
// name = "json-device-detection-lookup"
// description = "json device detection lookup test"
// authors = ["Test User <[email protected]>"]
// language = "rust"
// [local_server]
// [local_server.device_detection]
// file = "../test-fixtures/data/device-detection-mapping.json"
// format = "json"
// "#;
#[tokio::test(flavor = "multi_thread")]
async fn json_device_detection_lookup_works() -> TestResult {
const FASTLY_TOML: &str = r#"
name = "json-device-detection-lookup"
description = "json device detection lookup test"
authors = ["Test User <[email protected]>"]
language = "rust"
[local_server]
[local_server.device_detection]
file = "../test-fixtures/data/device-detection-mapping.json"
format = "json"
"#;

// let resp = Test::using_fixture("device-detection-lookup.wasm")
// .using_fastly_toml(FASTLY_TOML)?
// .against_empty()
// .await?;
let resp = Test::using_fixture("device-detection-lookup.wasm")
.using_fastly_toml(FASTLY_TOML)?
.against_empty()
.await?;

// assert_eq!(resp.status(), StatusCode::OK);
// assert!(to_bytes(resp.into_body())
// .await
// .expect("can read body")
// .to_vec()
// .is_empty());
assert_eq!(resp.status(), StatusCode::OK);
assert!(to_bytes(resp.into_body())
.await
.expect("can read body")
.to_vec()
.is_empty());

// Ok(())
// }
Ok(())
}

// #[tokio::test(flavor = "multi_thread")]
// async fn inline_toml_device_detection_lookup_works() -> TestResult {
// const FASTLY_TOML: &str = r#"
// name = "inline-toml-device-detection-lookup"
// description = "inline toml device detection lookup test"
// authors = ["Test User <[email protected]>"]
// language = "rust"
// [local_server]
// [local_server.device_detection]
// format = "inline-toml"
// [local_server.device_detection.user_agents]
// [local_server.device_detection.user_agents."Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 [FBAN/FBIOS;FBAV/8.0.0.28.18;FBBV/1665515;FBDV/iPhone4,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/7.0.4;FBSS/2; FBCR/Telekom.de;FBID/phone;FBLC/de_DE;FBOP/5]"]
// user_agent = {}
// os = {}
// device = {name = "iPhone", brand = "Apple", model = "iPhone4,1", hwtype = "Mobile Phone", is_ereader = false, is_gameconsole = false, is_mediaplayer = false, is_mobile = true, is_smarttv = false, is_tablet = false, is_tvplayer = false, is_desktop = false, is_touchscreen = true }
// [local_server.device_detection.user_agents."ghosts-app/1.0.2.1 (ASUSTeK COMPUTER INC.; X550CC; Windows 8 (X86); en)"]
// user_agent = {}
// os = {}
// device = {name = "Asus TeK", brand = "Asus", model = "TeK", is_desktop = false }
// "#;
#[tokio::test(flavor = "multi_thread")]
async fn inline_toml_device_detection_lookup_works() -> TestResult {
const FASTLY_TOML: &str = r#"
name = "inline-toml-device-detection-lookup"
description = "inline toml device detection lookup test"
authors = ["Test User <[email protected]>"]
language = "rust"
[local_server]
[local_server.device_detection]
format = "inline-toml"
[local_server.device_detection.user_agents]
[local_server.device_detection.user_agents."Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 [FBAN/FBIOS;FBAV/8.0.0.28.18;FBBV/1665515;FBDV/iPhone4,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/7.0.4;FBSS/2; FBCR/Telekom.de;FBID/phone;FBLC/de_DE;FBOP/5]"]
user_agent = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think table keys can contain [ or ]

Suggested change
[local_server.device_detection.user_agents."Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 [FBAN/FBIOS;FBAV/8.0.0.28.18;FBBV/1665515;FBDV/iPhone4,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/7.0.4;FBSS/2; FBCR/Telekom.de;FBID/phone;FBLC/de_DE;FBOP/5]"]
[local_server.device_detection.user_agents."Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 FBAN/FBIOS;FBAV/8.0.0.28.18;FBBV/1665515;FBDV/iPhone4,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/7.0.4;FBSS/2; FBCR/Telekom.de;FBID/phone;FBLC/de_DE;FBOP/5"]

os = {}
device = {name = "iPhone", brand = "Apple", model = "iPhone4,1", hwtype = "Mobile Phone", is_ereader = false, is_gameconsole = false, is_mediaplayer = false, is_mobile = true, is_smarttv = false, is_tablet = false, is_tvplayer = false, is_desktop = false, is_touchscreen = true }
[local_server.device_detection.user_agents."ghosts-app/1.0.2.1 (ASUSTeK COMPUTER INC.; X550CC; Windows 8 (X86); en)"]
user_agent = {}
os = {}
device = {name = "Asus TeK", brand = "Asus", model = "TeK", is_desktop = false }
"#;

// let resp = Test::using_fixture("device-detection-lookup.wasm")
// .using_fastly_toml(FASTLY_TOML)?
// .against_empty()
// .await?;
let resp = Test::using_fixture("device-detection-lookup.wasm")
.using_fastly_toml(FASTLY_TOML)?
.against_empty()
.await?;

// assert_eq!(resp.status(), StatusCode::OK);
// assert!(to_bytes(resp.into_body())
// .await
// .expect("can read body")
// .to_vec()
// .is_empty());
assert_eq!(resp.status(), StatusCode::OK);
assert!(to_bytes(resp.into_body())
.await
.expect("can read body")
.to_vec()
.is_empty());

// Ok(())
// }
Ok(())
}
Loading