Skip to content

Commit

Permalink
Fix indentation in tests (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb authored Apr 19, 2024
1 parent 785887e commit 8a56af3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,37 @@ root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true

[*.{json,table,toml,yml}]
indent_size = 2
indent_style = space

[butane_cli/src/main.rs]
max_line_length = 400

[butane_migrations.rs]
indent_size = unset
max_line_length = unset

[types.json]
max_line_length = unset

[README.md]
max_line_length = 200

[Makefile]
indent_style = tab

[notes.org]
indent_size = unset

[*.md]
indent_size = unset

[LICENSE-APACHE.txt]
indent_size = unset
16 changes: 8 additions & 8 deletions butane/tests/migration-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ fn migration_add_field_with_default_sqlite() {
"ALTER TABLE Foo ADD COLUMN baz INTEGER NOT NULL DEFAULT 42;",
// See comments on migration_add_field_sqlite
r#"CREATE TABLE Foo__butane_tmp (id INTEGER NOT NULL PRIMARY KEY,bar TEXT NOT NULL);
INSERT INTO Foo__butane_tmp SELECT id, bar FROM Foo;
DROP TABLE Foo;ALTER TABLE Foo__butane_tmp RENAME TO Foo;"#,
INSERT INTO Foo__butane_tmp SELECT id, bar FROM Foo;
DROP TABLE Foo;ALTER TABLE Foo__butane_tmp RENAME TO Foo;"#,
);
}

Expand Down Expand Up @@ -283,13 +283,13 @@ fn migration_add_and_remove_field_sqlite() {
// changes. If the change is innocuous, this test should just
// be updated.
r#"ALTER TABLE Foo ADD COLUMN baz INTEGER NOT NULL DEFAULT 0;
CREATE TABLE Foo__butane_tmp (id INTEGER NOT NULL PRIMARY KEY,baz INTEGER NOT NULL);
INSERT INTO Foo__butane_tmp SELECT id, baz FROM Foo;
DROP TABLE Foo;ALTER TABLE Foo__butane_tmp RENAME TO Foo;"#,
CREATE TABLE Foo__butane_tmp (id INTEGER NOT NULL PRIMARY KEY,baz INTEGER NOT NULL);
INSERT INTO Foo__butane_tmp SELECT id, baz FROM Foo;
DROP TABLE Foo;ALTER TABLE Foo__butane_tmp RENAME TO Foo;"#,
r#"ALTER TABLE Foo ADD COLUMN bar TEXT NOT NULL DEFAULT '';
CREATE TABLE Foo__butane_tmp (id INTEGER NOT NULL PRIMARY KEY,bar TEXT NOT NULL);
INSERT INTO Foo__butane_tmp SELECT id, bar FROM Foo;DROP TABLE Foo;
ALTER TABLE Foo__butane_tmp RENAME TO Foo;"#,
CREATE TABLE Foo__butane_tmp (id INTEGER NOT NULL PRIMARY KEY,bar TEXT NOT NULL);
INSERT INTO Foo__butane_tmp SELECT id, bar FROM Foo;DROP TABLE Foo;
ALTER TABLE Foo__butane_tmp RENAME TO Foo;"#,
);
}

Expand Down
6 changes: 3 additions & 3 deletions butane_core/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,13 @@ mod tests {
#[test]
fn test_is_foreign_key() {
let tokens = quote::quote! {
foos: butane::ForeignKey<Foo>
foos: butane::ForeignKey<Foo>
};
let field = syn::Field::parse_named.parse2(tokens).unwrap();
assert!(is_foreign_key(&field));

let tokens = quote::quote! {
foos: Option<butane::ForeignKey<Foo>>
foos: Option<butane::ForeignKey<Foo>>
};
let field = syn::Field::parse_named.parse2(tokens).unwrap();
assert!(is_foreign_key(&field));
Expand All @@ -697,7 +697,7 @@ mod tests {
assert!(!is_foreign_key(&field));

let tokens = quote::quote! {
foos: Option<SomethingElse>
foos: Option<SomethingElse>
};
let field = syn::Field::parse_named.parse2(tokens).unwrap();
assert!(!is_foreign_key(&field));
Expand Down
2 changes: 1 addition & 1 deletion examples/getting_started/src/butane_migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn get_migrations() -> Result<MemMigrations, butane::Error> {
},
"from": null,
"up": {
"pg": "CREATE TABLE Blog (\nid BIGSERIAL NOT NULL PRIMARY KEY,\n\"name\" TEXT NOT NULL\n);\nCREATE TABLE Post (\nid SERIAL NOT NULL PRIMARY KEY,\ntitle TEXT NOT NULL,\nbody TEXT NOT NULL,\npublished BOOLEAN NOT NULL,\nblog BIGINT NOT NULL,\nbyline TEXT \n);\nCREATE TABLE Post_tags_Many (\nowner INTEGER NOT NULL,\nhas TEXT NOT NULL\n);\nCREATE TABLE Tag (\ntag TEXT NOT NULL PRIMARY KEY\n);\nCREATE TABLE IF NOT EXISTS butane_migrations (\n\"name\" TEXT NOT NULL PRIMARY KEY\n);\n",
"pg": "CREATE TABLE Blog (\nid BIGSERIAL NOT NULL PRIMARY KEY,\n\"name\" TEXT NOT NULL\n);\nCREATE TABLE Post (\nid SERIAL NOT NULL PRIMARY KEY,\ntitle TEXT NOT NULL,\nbody TEXT NOT NULL,\npublished BOOLEAN NOT NULL,\nblog BIGINT NOT NULL,\nbyline TEXT\n);\nCREATE TABLE Post_tags_Many (\nowner INTEGER NOT NULL,\nhas TEXT NOT NULL\n);\nCREATE TABLE Tag (\ntag TEXT NOT NULL PRIMARY KEY\n);\nCREATE TABLE IF NOT EXISTS butane_migrations (\n\"name\" TEXT NOT NULL PRIMARY KEY\n);\n",
"sqlite": "CREATE TABLE Blog (\nid INTEGER NOT NULL PRIMARY KEY,\n\"name\" TEXT NOT NULL\n);\nCREATE TABLE Post (\nid INTEGER NOT NULL PRIMARY KEY,\ntitle TEXT NOT NULL,\nbody TEXT NOT NULL,\npublished INTEGER NOT NULL,\nblog INTEGER NOT NULL,\nbyline TEXT\n);\nCREATE TABLE Post_tags_Many (\nowner INTEGER NOT NULL,\nhas TEXT NOT NULL\n);\nCREATE TABLE Tag (\ntag TEXT NOT NULL PRIMARY KEY\n);\nCREATE TABLE IF NOT EXISTS butane_migrations (\n\"name\" TEXT NOT NULL PRIMARY KEY\n);\n"
},
"down": {
Expand Down

0 comments on commit 8a56af3

Please sign in to comment.