Skip to content

Commit 057c43b

Browse files
Refactor tests
1 parent 4e14211 commit 057c43b

File tree

1 file changed

+2
-135
lines changed

1 file changed

+2
-135
lines changed

tests/tui_cases/pagination.rs

Lines changed: 2 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -75,138 +75,5 @@ async fn single_page() {
7575
assert_eq!(table_state.borrow().selected(), None);
7676
}
7777

78-
// Tests that we can paginate through multiple pages and go back to the first page
79-
#[tokio::test(flavor = "multi_thread")]
80-
async fn multiple_pages_forward_and_back() {
81-
let mut test_app = TestApp::new().await;
82-
let res1 = create_execution_results("SELECT 1", 0);
83-
let event1 = AppEvent::ExecutionResultsNextBatch(res1);
84-
85-
test_app.handle_app_event(AppEvent::NewExecution).unwrap();
86-
test_app.handle_app_event(event1).unwrap();
87-
88-
{
89-
let state = test_app.state();
90-
let page = state.sql_tab.current_page().unwrap();
91-
assert_eq!(page, 0);
92-
}
93-
94-
let res2 = create_execution_results("SELECT 1", 1);
95-
let event2 = AppEvent::ExecutionResultsNextBatch(res2);
96-
test_app.handle_app_event(event2).unwrap();
97-
98-
{
99-
let state = test_app.state();
100-
let page = state.sql_tab.current_page().unwrap();
101-
assert_eq!(page, 1);
102-
}
103-
104-
{
105-
let state = test_app.state();
106-
let batch = state.sql_tab.current_page_results();
107-
assert!(batch.is_some());
108-
109-
let batch = batch.unwrap();
110-
let batches = vec![batch];
111-
let expected = [
112-
"+---+---+",
113-
"| a | b |",
114-
"+---+---+",
115-
"| 2 | 4 |",
116-
"| 3 | 5 |",
117-
"+---+---+",
118-
];
119-
assert_batches_eq!(expected, &batches);
120-
}
121-
122-
let left_key = crossterm::event::KeyEvent::new(
123-
crossterm::event::KeyCode::Left,
124-
crossterm::event::KeyModifiers::NONE,
125-
);
126-
let event3 = AppEvent::Key(left_key);
127-
test_app.handle_app_event(event3).unwrap();
128-
129-
{
130-
let state = test_app.state();
131-
let page = state.sql_tab.current_page().unwrap();
132-
assert_eq!(page, 0);
133-
}
134-
135-
{
136-
let state = test_app.state();
137-
let batch = state.sql_tab.current_page_results();
138-
assert!(batch.is_some());
139-
140-
let batch = batch.unwrap();
141-
let batches = vec![batch];
142-
let expected = [
143-
"+---+---+",
144-
"| a | b |",
145-
"+---+---+",
146-
"| 1 | 3 |",
147-
"| 2 | 4 |",
148-
"+---+---+",
149-
];
150-
assert_batches_eq!(expected, &batches);
151-
}
152-
}
153-
154-
// Tests that we can still paginate when we already have the batch because we previously viewed the
155-
// page
156-
#[tokio::test(flavor = "multi_thread")]
157-
async fn multiple_pages_forward_and_back_and_forward() {
158-
let mut test_app = TestApp::new().await;
159-
let res1 = create_execution_results("SELECT 1", 0);
160-
let event1 = AppEvent::ExecutionResultsNextBatch(res1);
161-
162-
test_app.handle_app_event(AppEvent::NewExecution).unwrap();
163-
test_app.handle_app_event(event1).unwrap();
164-
165-
{
166-
let state = test_app.state();
167-
let page = state.sql_tab.current_page().unwrap();
168-
assert_eq!(page, 0);
169-
}
170-
171-
let res2 = create_execution_results("SELECT 1", 1);
172-
let event2 = AppEvent::ExecutionResultsNextBatch(res2);
173-
test_app.handle_app_event(event2).unwrap();
174-
175-
let left_key = crossterm::event::KeyEvent::new(
176-
crossterm::event::KeyCode::Left,
177-
crossterm::event::KeyModifiers::NONE,
178-
);
179-
let event3 = AppEvent::Key(left_key);
180-
test_app.handle_app_event(event3).unwrap();
181-
182-
let right_key = crossterm::event::KeyEvent::new(
183-
crossterm::event::KeyCode::Right,
184-
crossterm::event::KeyModifiers::NONE,
185-
);
186-
let event4 = AppEvent::Key(right_key);
187-
test_app.handle_app_event(event4).unwrap();
188-
189-
{
190-
let state = test_app.state();
191-
let page = state.sql_tab.current_page().unwrap();
192-
assert_eq!(page, 1);
193-
}
194-
195-
{
196-
let state = test_app.state();
197-
let batch = state.sql_tab.current_page_results();
198-
assert!(batch.is_some());
199-
200-
let batch = batch.unwrap();
201-
let batches = vec![batch];
202-
let expected = [
203-
"+---+---+",
204-
"| a | b |",
205-
"+---+---+",
206-
"| 2 | 4 |",
207-
"| 3 | 5 |",
208-
"+---+---+",
209-
];
210-
assert_batches_eq!(expected, &batches);
211-
}
212-
}
78+
// NOTE: The old batch-based pagination tests have been removed.
79+
// See sql_pagination.rs for proper row-based pagination tests.

0 commit comments

Comments
 (0)