MCPcopy Create free account
hub / github.com/douglance/devsql / test_query_result_to_json

Function test_query_result_to_json

crates/vcsql/tests/integration.rs:142–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

140
141#[test]
142fn test_query_result_to_json() {
143 let temp = create_test_repo();
144 let mut repo = GitRepo::open(temp.path()).expect("Failed to open repo");
145 let mut engine = SqlEngine::new().expect("Failed to create engine");
146
147 engine
148 .load_tables_for_query("SELECT * FROM commits", &mut repo)
149 .expect("Failed to load tables");
150
151 let result = engine
152 .execute("SELECT short_id, summary FROM commits LIMIT 1")
153 .expect("Failed to execute query");
154
155 let json = result.to_json_array();
156 assert_eq!(json.len(), 1, "Should have 1 JSON object");
157 assert!(json[0].is_object(), "Should be a JSON object");
158 assert!(json[0].get("short_id").is_some(), "Should have short_id");
159 assert!(json[0].get("summary").is_some(), "Should have summary");
160}
161
162#[test]
163fn test_table_not_found() {

Callers

nothing calls this directly

Calls 5

pathMethod · 0.80
load_tables_for_queryMethod · 0.80
to_json_arrayMethod · 0.80
create_test_repoFunction · 0.70
executeMethod · 0.45

Tested by

no test coverage detected