column_loop_test

Function column_loop_test 

Source
pub fn column_loop_test(
    num_columns: i32,
    migration_name: String,
) -> Result<String, Error>
Expand description

§Name: column_loop_test

§Description:

This function is used to test the column loop

§Arguments:

  • num_columns - The number of columns to create
  • migration_name - The name of the migration

§Returns:

  • Result<String, Error> - The up sql contents

§Example

use rustyroad::database::migrations::column_loop;
use rustyline::DefaultEditor;
use rustyroad::database::{column_loop_test, PostgresTypes};


let column_loop = column_loop_test(1, String::from("test"));

match column_loop {
   Ok(column_loop) => {
      // Assert the column_loop is equal the generated sql with the column name and column type
     assert_eq!(column_loop, String::from("CREATE TABLE test (test Integer[] NOT NULL UNIQUE);"));
  },
 Err(e) => {
   panic!("Failed to get column loop: {}", e.to_string());
  }
}