-
Notifications
You must be signed in to change notification settings - Fork 13
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
Feat/sql pagination 2 #157
Merged
matthewmturner
merged 20 commits into
datafusion-contrib:main
from
matthewmturner:feat/sql-pagination-2
Sep 23, 2024
+844
−328
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
16f2fc7
Start setting up pagination
matthewmturner 93e6ba3
Playing around with execution structure to paginate
matthewmturner b739d38
Resolve conflicts
matthewmturner 52802d6
SQL results displaying
matthewmturner a9becce
New paginating model
matthewmturner 368e2b0
Resolve conflicts
matthewmturner f353519
More refactoring for pagination
matthewmturner 8af0c8a
Better history and pagination handling
matthewmturner 07ba750
Cleanup
matthewmturner cb050d9
Next and previous page working for sql tab
matthewmturner 09c7d68
Resolve conflicts
matthewmturner cd5820e
SQL pagination
matthewmturner 9d48257
Cleanup
matthewmturner e262353
Update test structure for tui
matthewmturner 7ed0037
Rename
matthewmturner 764c1de
Pagination tests
matthewmturner 8612d65
Cleanup
matthewmturner d88fe60
Fix logic for paginating with existing results
matthewmturner 5a7d805
Fix
matthewmturner 0818503
Resolve conflicts
matthewmturner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update test structure for tui
- Loading branch information
commit e2623533d71a8cf7e21d1c772f617bc25cac0616
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
|
||
mod quit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
//! Tests for the TUI (e.g. user application with keyboard commands) | ||
|
||
use dft::app::state::initialize; | ||
use dft::app::{App, AppEvent}; | ||
use dft::execution::ExecutionContext; | ||
use ratatui::crossterm::event; | ||
use tempfile::{tempdir, TempDir}; | ||
|
||
#[tokio::test] | ||
async fn construct_with_no_args() { | ||
let _test_app = TestApp::new(); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_sql_tab() { | ||
let mut test_app = TestApp::new(); | ||
// SQL Tab | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
// Ideally, we figure out a way to check that the app actually quits | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_flightsql_tab() { | ||
let mut test_app = TestApp::new(); | ||
let flightsql_key = event::KeyEvent::new(event::KeyCode::Char('2'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(flightsql_key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_history_tab() { | ||
let mut test_app = TestApp::new(); | ||
let history_key = event::KeyEvent::new(event::KeyCode::Char('3'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(history_key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_logs_tab() { | ||
let mut test_app = TestApp::new(); | ||
let logs_key = event::KeyEvent::new(event::KeyCode::Char('4'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(logs_key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_context_tab() { | ||
let mut test_app = TestApp::new(); | ||
let context_key = event::KeyEvent::new(event::KeyCode::Char('5'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(context_key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
/// Fixture with an [`App`] instance and other temporary state | ||
struct TestApp<'app> { | ||
/// Temporary directory for configuration files | ||
/// | ||
/// The directory is removed when the object is dropped so this | ||
/// field must remain alive while the app is running | ||
#[allow(dead_code)] | ||
config_path: TempDir, | ||
/// The [`App`] instance | ||
app: App<'app>, | ||
} | ||
|
||
impl<'app> TestApp<'app> { | ||
/// Create a new [`TestApp`] instance configured with a temporary directory | ||
fn new() -> Self { | ||
let config_path = tempdir().unwrap(); | ||
let state = initialize(config_path.path().to_path_buf()); | ||
let execution = ExecutionContext::try_new(&state.config.execution).unwrap(); | ||
let app = App::new(state, execution); | ||
Self { config_path, app } | ||
} | ||
|
||
/// Call app.event_handler with the given event | ||
pub fn handle_app_event(&mut self, event: AppEvent) -> color_eyre::Result<()> { | ||
self.app.handle_app_event(event) | ||
} | ||
|
||
/// Return the app state | ||
pub fn state(&self) -> &dft::app::state::AppState { | ||
self.app.state() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
//! Tests for the TUI (e.g. user application with keyboard commands) | ||
|
||
use dft::app::state::initialize; | ||
use dft::app::{App, AppEvent}; | ||
use dft::execution::ExecutionContext; | ||
use ratatui::crossterm::event; | ||
use tempfile::{tempdir, TempDir}; | ||
|
||
#[tokio::test] | ||
async fn construct_with_no_args() { | ||
let _test_app = TestApp::new(); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_sql_tab() { | ||
let mut test_app = TestApp::new(); | ||
// SQL Tab | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
// Ideally, we figure out a way to check that the app actually quits | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_flightsql_tab() { | ||
let mut test_app = TestApp::new(); | ||
let flightsql_key = event::KeyEvent::new(event::KeyCode::Char('2'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(flightsql_key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_history_tab() { | ||
let mut test_app = TestApp::new(); | ||
let history_key = event::KeyEvent::new(event::KeyCode::Char('3'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(history_key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_logs_tab() { | ||
let mut test_app = TestApp::new(); | ||
let logs_key = event::KeyEvent::new(event::KeyCode::Char('4'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(logs_key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
assert!(test_app.state().should_quit); | ||
} | ||
|
||
#[tokio::test] | ||
async fn quit_app_from_context_tab() { | ||
let mut test_app = TestApp::new(); | ||
let context_key = event::KeyEvent::new(event::KeyCode::Char('5'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(context_key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
let key = event::KeyEvent::new(event::KeyCode::Char('q'), event::KeyModifiers::NONE); | ||
let app_event = AppEvent::Key(key); | ||
test_app.handle_app_event(app_event).unwrap(); | ||
assert!(test_app.state().should_quit); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.