Skip to content

Commit 79be2ce

Browse files
committed
ci: fix CSV tests
1 parent d98b7f5 commit 79be2ce

6 files changed

Lines changed: 17 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Temporary Items
3434
# End of https://www.toptal.com/developers/gitignore/api/rust,macos
3535
*.json
3636
*.csv
37+
!test_commands.csv
38+
!tests/fixtures/*.csv
3739
*.bundle
3840
assets/zoom_iterm.scpt
3941
assets/zoom_iterm.scpt

src/csv.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ mod tests {
229229

230230
#[test]
231231
fn test_read_commands_from_csv_valid_csv() {
232-
let path = "tests/fixtures/commands.csv"; // Must be a real file with no prompts
233-
let commands = read_commands_from_csv(path).expect("Should parse CSV");
232+
let commands =
233+
read_commands_from_csv("tests/fixtures/commands.csv").expect("Should parse CSV");
234234

235235
assert_eq!(commands.len(), 2);
236236
assert_eq!(commands[0].display_name, "List Files");
@@ -239,15 +239,14 @@ mod tests {
239239

240240
#[test]
241241
fn test_read_commands_from_invalid_csv() {
242-
let path = "tests/fixtures/invalid.csv"; // Create this with garbage data
243-
let result = read_commands_from_csv(path);
242+
let result = read_commands_from_csv("tests/fixtures/invalid.csv");
244243
assert!(result.is_err());
245244
}
246245

247246
#[test]
248247
fn test_read_commands_from_empty_csv() {
249-
let path = "tests/fixtures/empty.csv";
250-
let commands = read_commands_from_csv(path).expect("Should parse empty CSV");
248+
let commands =
249+
read_commands_from_csv("tests/fixtures/empty.csv").expect("Should parse empty CSV");
251250
assert!(commands.is_empty());
252251
}
253252
}

test_commands.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
display_name,command
2+
Test Command 1,test_command_1
3+
Test Command 2,test_command_2

tests/fixtures/commands.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
display_name,command
2+
List Files,ls -la
3+
Show Date,date

tests/fixtures/empty.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
display_name,command

tests/fixtures/invalid.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
this,is,not,valid
2+
data,with,wrong,columns
3+
missing,header

0 commit comments

Comments
 (0)