|
| 1 | +use assert_cmd::prelude::*; |
| 2 | +use dir_diff; |
| 3 | +use std::process::Command; |
| 4 | +use tempdir; |
| 5 | +use tempdir::TempDir; |
| 6 | + |
| 7 | +#[test] |
| 8 | +fn test_go_help() { |
| 9 | + let path = "../gen_license/genlicense/__init_.py"; |
| 10 | + let mut cmd = Command::new("python"); |
| 11 | + cmd.arg("-h"); |
| 12 | + // assert_eq!(output, help); |
| 13 | + let assert = cmd.assert(); |
| 14 | + assert.success().stdout( |
| 15 | + r#"gen-license-go is a 996.icu license generator implemented in Go, |
| 16 | +this generator is developed to generate various open-source licenses including MIT, Apache, etc. |
| 17 | +More importantly, the main purpose of this tool is to incorporate those aforesaid licenses into |
| 18 | +a brand new license: 996.icu, defined by this repository. |
| 19 | +
|
| 20 | +Usage: |
| 21 | + gen-license-go [flags] |
| 22 | + gen-license-go [command] |
| 23 | +
|
| 24 | +Available Commands: |
| 25 | + gen gen is a 996.icu license generator-command. |
| 26 | + help Help about any command |
| 27 | +
|
| 28 | +Flags: |
| 29 | + -h, --help help for gen-license-go |
| 30 | + -l, --list list all licenses (default true) |
| 31 | +
|
| 32 | +Use "gen-license-go [command] --help" for more information about a command."#, |
| 33 | + ); |
| 34 | +} |
| 35 | + |
| 36 | +#[test] |
| 37 | +fn test_py_create_license_mit() { |
| 38 | + let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); |
| 39 | + let path = "../gen_license/genlicense/__init_.py"; |
| 40 | + let mut cmd = Command::new("python"); |
| 41 | + cmd.arg("gen").arg("mit").arg("--996icu").args("en-us"); |
| 42 | + assert!( |
| 43 | + !dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/mit.txt").unwrap() |
| 44 | + ); |
| 45 | +} |
| 46 | + |
| 47 | +#[test] |
| 48 | +fn test_py_create_license_mit() { |
| 49 | + let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); |
| 50 | + let path = "../gen_license/genlicense/__init_.py"; |
| 51 | + let mut cmd = Command::new("python"); |
| 52 | + cmd.arg("gen").arg("mit").arg("--996icu").args("en-us"); |
| 53 | + assert!( |
| 54 | + !dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/mit.txt").unwrap() |
| 55 | + ); |
| 56 | +} |
| 57 | +#[test] |
| 58 | +fn test_py_create_license_epl() { |
| 59 | + let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); |
| 60 | + let path = "../gen_license/genlicense/__init_.py"; |
| 61 | + let mut cmd = Command::new("python"); |
| 62 | + cmd.arg("gen").arg("epl").arg("--996icu").args("en-us"); |
| 63 | + assert!( |
| 64 | + !dir_diff::is_different(&tmp_dir.path(), "../../gen-license/licenses/epl-2.txt").unwrap() |
| 65 | + ); |
| 66 | +} |
| 67 | +#[test] |
| 68 | +fn test_py_create_license_gpl() { |
| 69 | + let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); |
| 70 | + let path = "../gen_license/genlicense/__init_.py"; |
| 71 | + let mut cmd = Command::new("python"); |
| 72 | + cmd.arg("gen").arg("gpl").arg("--996icu").args("en-us"); |
| 73 | + assert!( |
| 74 | + !dir_diff::is_different(&tmp_dir.path(), "../../gen-license/licenses/gpl.txt").unwrap() |
| 75 | + ); |
| 76 | +} |
0 commit comments