-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
getting started integration tests #4087
Changes from 7 commits
d6f143b
e8c9869
af4c7d8
8266d3c
d843672
5dc3a84
1f287f5
ea39b06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn show_posts() { | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ publish = false | |
[dependencies] | ||
diesel = { version = "2.1.0", path = "../../../diesel", features = ["mysql"] } | ||
dotenvy = "0.15" | ||
assert_cmd = "2.0.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
|
||
[[bin]] | ||
name = "show_posts" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn write_post() { | ||
let _ = Command::cargo_bin("write_post") | ||
.unwrap() | ||
.write_stdin("Test Title\ntest text\n1 2 3") | ||
.assert() | ||
.append_context("write_post", "") | ||
.stdout( | ||
"What would you like your title to be?\n\nOk! Let's write Test Title (Press " | ||
.to_owned() | ||
+ EOF | ||
+ " when finished)\n\n\nSaved draft Test Title with id 1\n", | ||
); | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} | ||
|
||
#[cfg(not(windows))] | ||
const EOF: &str = "CTRL+D"; | ||
|
||
#[cfg(windows)] | ||
const EOF: &str = "CTRL+Z"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ publish = false | |
[dependencies] | ||
diesel = { version = "2.1.0", path = "../../../diesel", features = ["mysql"] } | ||
dotenvy = "0.15" | ||
assert_cmd = "2.0.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
|
||
[[bin]] | ||
name = "show_posts" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn publish_post() { | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
|
||
let _ = Command::cargo_bin("write_post") | ||
.unwrap() | ||
.write_stdin("Test Title\ntest text\n1 2 3") | ||
.assert() | ||
.append_context("write_post", "") | ||
.stdout( | ||
"What would you like your title to be?\n\nOk! Let's write Test Title (Press " | ||
.to_owned() | ||
+ EOF | ||
+ " when finished)\n\n\nSaved draft Test Title with id 1\n", | ||
); | ||
|
||
let _ = Command::cargo_bin("publish_post") | ||
.unwrap() | ||
.arg("1") | ||
.assert() | ||
.append_context("publish_post", "") | ||
.stdout("Published post Test Title\n"); | ||
|
||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 1 posts\nTest Title\n-----------\n\ntest text\n1 2 3\n"); | ||
|
||
let _ = Command::cargo_bin("delete_post") | ||
.unwrap() | ||
.arg("Test Title") | ||
.assert() | ||
.append_context("delete_post", "") | ||
.stdout("Deleted 1 posts\n"); | ||
|
||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} | ||
|
||
#[cfg(not(windows))] | ||
const EOF: &str = "CTRL+D"; | ||
|
||
#[cfg(windows)] | ||
const EOF: &str = "CTRL+Z"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ publish = false | |
[dependencies] | ||
diesel = { version = "2.1.0", path = "../../../diesel", features = ["postgres"] } | ||
dotenvy = "0.15" | ||
assert_cmd = "2.0.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
|
||
[[bin]] | ||
name = "show_posts" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn show_posts() { | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ publish = false | |
[dependencies] | ||
diesel = { version = "2.1.0", path = "../../../diesel", features = ["postgres"] } | ||
dotenvy = "0.15" | ||
assert_cmd = "2.0.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
|
||
[[bin]] | ||
name = "show_posts" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn write_post() { | ||
let _ = Command::cargo_bin("write_post") | ||
.unwrap() | ||
.write_stdin("Test Title\ntest text\n1 2 3") | ||
.assert() | ||
.append_context("write_post", "") | ||
.stdout( | ||
"What would you like your title to be?\n\nOk! Let's write Test Title (Press " | ||
.to_owned() | ||
+ EOF | ||
+ " when finished)\n\n\nSaved draft Test Title with id 1\n", | ||
); | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} | ||
|
||
#[cfg(not(windows))] | ||
const EOF: &str = "CTRL+D"; | ||
|
||
#[cfg(windows)] | ||
const EOF: &str = "CTRL+Z"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ publish = false | |
[dependencies] | ||
diesel = { version = "2.1.0", path = "../../../diesel", features = ["postgres"] } | ||
dotenvy = "0.15" | ||
assert_cmd = "2.0.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
|
||
[[bin]] | ||
name = "show_posts" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn publish_post() { | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
|
||
let _ = Command::cargo_bin("write_post") | ||
.unwrap() | ||
.write_stdin("Test Title\ntest text\n1 2 3") | ||
.assert() | ||
.append_context("write_post", "") | ||
.stdout( | ||
"What would you like your title to be?\n\nOk! Let's write Test Title (Press " | ||
.to_owned() | ||
+ EOF | ||
+ " when finished)\n\n\nSaved draft Test Title with id 1\n", | ||
); | ||
|
||
let _ = Command::cargo_bin("publish_post") | ||
.unwrap() | ||
.arg("1") | ||
.assert() | ||
.append_context("publish_post", "") | ||
.stdout("Published post Test Title\n"); | ||
|
||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 1 posts\nTest Title\n-----------\n\ntest text\n1 2 3\n"); | ||
|
||
let _ = Command::cargo_bin("delete_post") | ||
.unwrap() | ||
.arg("Test Title") | ||
.assert() | ||
.append_context("delete_post", "") | ||
.stdout("Deleted 1 posts\n"); | ||
|
||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} | ||
|
||
#[cfg(not(windows))] | ||
const EOF: &str = "CTRL+D"; | ||
|
||
#[cfg(windows)] | ||
const EOF: &str = "CTRL+Z"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ publish = false | |
diesel = { version = "2.1.0", path = "../../../diesel", features = ["sqlite"] } | ||
dotenvy = "0.15" | ||
libsqlite3-sys = { version = "0.28.0", features = ["bundled"] } | ||
assert_cmd = "2.0.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
|
||
[[bin]] | ||
name = "show_posts" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn show_posts() { | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ publish = false | |
diesel = { version = "2.1.0", path = "../../../diesel", features = ["sqlite", "returning_clauses_for_sqlite_3_35"] } | ||
dotenvy = "0.15" | ||
libsqlite3-sys = { version = "0.28.0", features = ["bundled"] } | ||
assert_cmd = "2.0.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
|
||
[[bin]] | ||
name = "show_posts" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn write_post() { | ||
let _ = Command::cargo_bin("write_post") | ||
.unwrap() | ||
.write_stdin("Test Title\ntest text\n1 2 3") | ||
.assert() | ||
.append_context("write_post", "") | ||
.stdout( | ||
"What would you like your title to be?\n\nOk! Let's write Test Title (Press " | ||
.to_owned() | ||
+ EOF | ||
+ " when finished)\n\n\nSaved draft Test Title with id 1\n", | ||
); | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} | ||
|
||
#[cfg(not(windows))] | ||
const EOF: &str = "CTRL+D"; | ||
|
||
#[cfg(windows)] | ||
const EOF: &str = "CTRL+Z"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ publish = false | |
diesel = { version = "2.1.0", path = "../../../diesel", features = ["sqlite", "returning_clauses_for_sqlite_3_35"] } | ||
dotenvy = "0.15" | ||
libsqlite3-sys = { version = "0.28.0", features = ["bundled"] } | ||
assert_cmd = "2.0.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
|
||
[[bin]] | ||
name = "show_posts" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn publish_post() { | ||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
|
||
let _ = Command::cargo_bin("write_post") | ||
.unwrap() | ||
.write_stdin("Test Title\ntest text\n1 2 3") | ||
.assert() | ||
.append_context("write_post", "") | ||
.stdout( | ||
"What would you like your title to be?\n\nOk! Let's write Test Title (Press " | ||
.to_owned() | ||
+ EOF | ||
+ " when finished)\n\n\nSaved draft Test Title with id 1\n", | ||
); | ||
|
||
let _ = Command::cargo_bin("publish_post") | ||
.unwrap() | ||
.arg("1") | ||
.assert() | ||
.append_context("publish_post", "") | ||
.stdout("Published post Test Title\n"); | ||
|
||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 1 posts\nTest Title\n-----------\n\ntest text\n1 2 3\n"); | ||
|
||
let _ = Command::cargo_bin("delete_post") | ||
.unwrap() | ||
.arg("Test Title") | ||
.assert() | ||
.append_context("delete_post", "") | ||
.stdout("Deleted 1 posts\n"); | ||
|
||
let _ = Command::cargo_bin("show_posts") | ||
.unwrap() | ||
.assert() | ||
.append_context("show_posts", "") | ||
.stdout("Displaying 0 posts\n"); | ||
} | ||
|
||
#[cfg(not(windows))] | ||
const EOF: &str = "CTRL+D"; | ||
|
||
#[cfg(windows)] | ||
const EOF: &str = "CTRL+Z"; |
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.
This should be a
dev-dependency
as we only use that in tests