Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sabati committed Apr 24, 2024
1 parent 9eda267 commit 1ff4ad9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions diesel_cli/tests/print_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ fn run_infer_schema_without_docs() {
test_print_schema("print_schema_simple_without_docs", vec![]);
}

#[test]
fn run_skip_missing_sql_types_definitions() {
test_print_schema("print_schema_skip_missing_sql_type_definitions", vec![]);
}

#[test]
fn run_infer_schema() {
test_print_schema("print_schema_simple", vec!["--with-docs"]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[print_schema]
file = "src/schema.rs"
generate_missing_sql_type_definitions = true
skip_missing_sql_type_definitions = ["MyType2"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: diesel_cli/tests/print_schema.rs
description: "Test: print_schema_custom_types_check_default_derives"
---
// @generated automatically by Diesel CLI.

pub mod sql_types {
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "my_type"))]
pub struct MyType;
}

diesel::table! {
use diesel::sql_types::*;
use super::sql_types::MyType;

custom_types (id) {
id -> Int4,
custom_enum -> MyType,
custom_enum_nullable -> Nullable<MyType>,
custom_enum2 -> MyType2,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TYPE my_type AS ENUM ('foo', 'bar');
CREATE TYPE my_type2 AS ENUM ('foo', 'bar');
CREATE TABLE custom_types (
id SERIAL PRIMARY KEY,
custom_enum my_type NOT NULL,
custom_enum_nullable my_type,
custom_enum2 my_type2 NOT NULL
);

0 comments on commit 1ff4ad9

Please sign in to comment.