Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs;
use std::path::{Path, PathBuf};
use std::{env, fs};

fn generate_snippet_test(snippet: &str, name: &str, dir: &Path) {
fn generate_snippet_test(snippet: &str, name: &str, dir: impl AsRef<Path>) {
// Pad each line of the snippet with 8 spaces

let snippet = snippet
Expand All @@ -26,7 +26,7 @@ async fn test_{name}() {{
);

// Write the test snippet to the file
let mut test_snippet_path = PathBuf::from(dir);
let mut test_snippet_path = PathBuf::from(dir.as_ref());
test_snippet_path.push(format!("test_{name}.rs"));
fs::write(test_snippet_path, test_snippet).unwrap();
}
Expand All @@ -37,14 +37,15 @@ fn main() {
#[cfg(not(feature = "generate-snippets"))]
return;

let out_dir = env::var_os("OUT_DIR").unwrap();
// Open all files in the `./tests/snippets` directory and save them to the `./tests/snippets_converted` directory
// Wrap text in the `tests/test_snippets.rs` file into { }
let snippets_dir = Path::new("./tests/snippets");
let tests_output_dir = Path::new("./tests/snippet_tests");
let tests_output_dir = Path::new(&out_dir).join("tests/snippet_tests");

// Create the converted directory if it doesn't exist
if !tests_output_dir.exists() {
fs::create_dir_all(tests_output_dir).unwrap();
fs::create_dir_all(&tests_output_dir).unwrap();
}

let mut snippet_names: Vec<_> = fs::read_dir(snippets_dir)
Expand All @@ -65,7 +66,7 @@ fn main() {

for (path, name) in &snippet_names {
let content = fs::read_to_string(path).unwrap();
generate_snippet_test(&content, name, tests_output_dir);
generate_snippet_test(&content, name, &tests_output_dir);
}

// Generate `tests/snippet_tests/mod.rs` file
Expand All @@ -77,7 +78,7 @@ fn main() {
.collect::<Vec<_>>()
.join("\n");

let mut mod_file_path = PathBuf::from(tests_output_dir);
let mut mod_file_path = PathBuf::from(&tests_output_dir);
mod_file_path.push("mod.rs");
fs::write(mod_file_path, mod_file).unwrap();
}
2 changes: 1 addition & 1 deletion tests/integration-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
50 changes: 0 additions & 50 deletions tests/snippet_tests/mod.rs

This file was deleted.

66 changes: 0 additions & 66 deletions tests/snippet_tests/test_batch_update.rs

This file was deleted.

22 changes: 0 additions & 22 deletions tests/snippet_tests/test_clear_payload.rs

This file was deleted.

15 changes: 0 additions & 15 deletions tests/snippet_tests/test_collection_exists.rs

This file was deleted.

25 changes: 0 additions & 25 deletions tests/snippet_tests/test_count_points.rs

This file was deleted.

21 changes: 0 additions & 21 deletions tests/snippet_tests/test_create_collection.rs

This file was deleted.

28 changes: 0 additions & 28 deletions tests/snippet_tests/test_create_collection_with_bq.rs

This file was deleted.

24 changes: 0 additions & 24 deletions tests/snippet_tests/test_create_field_index.rs

This file was deleted.

15 changes: 0 additions & 15 deletions tests/snippet_tests/test_create_full_snapshot.rs

This file was deleted.

24 changes: 0 additions & 24 deletions tests/snippet_tests/test_create_shard_key.rs

This file was deleted.

15 changes: 0 additions & 15 deletions tests/snippet_tests/test_create_snapshot.rs

This file was deleted.

Loading