Skip to content

Commit e3bcd00

Browse files
committed
worker/jobs/downloads: Add tests for ProcessCdnLog
1 parent 4569fec commit e3bcd00

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/worker/jobs/downloads.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,50 @@ impl ProcessCdnLog {
129129
Ok(())
130130
}
131131
}
132+
133+
#[cfg(test)]
134+
mod tests {
135+
use super::*;
136+
137+
#[tokio::test]
138+
async fn test_process_cdn_log() {
139+
let _guard = crate::util::tracing::init_for_test();
140+
141+
let path = "cloudfront/index.staging.crates.io/E35K556QRQDZXW.2024-01-16-16.d01d5f13.gz";
142+
143+
let job = ProcessCdnLog::new(
144+
"us-west-1".to_string(),
145+
"bucket".to_string(),
146+
path.to_string(),
147+
);
148+
149+
let config = CdnLogStorageConfig::memory();
150+
let store = assert_ok!(job.build_store(&config));
151+
152+
// Add dummy data into the store
153+
{
154+
let bytes =
155+
include_bytes!("../../../crates_io_cdn_logs/test_data/cloudfront/basic.log.gz");
156+
157+
store.put(&path.into(), bytes[..].into()).await.unwrap();
158+
}
159+
160+
assert_ok!(job.run(store).await);
161+
}
162+
163+
#[tokio::test]
164+
async fn test_s3_builder() {
165+
let path = "cloudfront/index.staging.crates.io/E35K556QRQDZXW.2024-01-16-16.d01d5f13.gz";
166+
167+
let job = ProcessCdnLog::new(
168+
"us-west-1".to_string(),
169+
"bucket".to_string(),
170+
path.to_string(),
171+
);
172+
173+
let access_key = "access_key".into();
174+
let secret_key = "secret_key".to_string().into();
175+
let config = CdnLogStorageConfig::s3(access_key, secret_key);
176+
assert_ok!(job.build_store(&config));
177+
}
178+
}

0 commit comments

Comments
 (0)