---
to: "{{ project_name }}/tests/integration_test.rs"
sparql:
  nouns: |
    PREFIX cli: <http://ggen.dev/schema/cli#>
    PREFIX cnv: <http://ggen.dev/schema/clap-noun-verb#>
    SELECT ?nounName
    WHERE {
      ?project a cli:CliProject ;
               cli:hasNoun ?noun .
      ?noun cnv:nounName ?nounName .
    }
    ORDER BY ?nounName
  all_verbs: |
    PREFIX cli: <http://ggen.dev/schema/cli#>
    PREFIX cnv: <http://ggen.dev/schema/clap-noun-verb#>
    SELECT ?nounName ?verbName
    WHERE {
      ?project a cli:CliProject ;
               cli:hasNoun ?noun .
      ?noun cnv:nounName ?nounName ;
            cnv:hasVerb ?verb .
      ?verb cnv:verbName ?verbName .
    }
    ORDER BY ?nounName ?verbName
---
//! Integration tests for {{ project_name }}

use assert_cmd::Command;
use assert_fs::prelude::*;
use predicates::prelude::*;

#[test]
fn test_help() {
    let mut cmd = Command::cargo_bin("{{ project_name }}").unwrap();
    cmd.arg("--help");
    cmd.assert()
        .success()
        .stdout(predicate::str::contains("{{ project_name }}"));
}

#[test]
fn test_version() {
    let mut cmd = Command::cargo_bin("{{ project_name }}").unwrap();
    cmd.arg("--version");
    cmd.assert()
        .success()
        .stdout(predicate::str::contains(env!("CARGO_PKG_VERSION")));
}

{% for verb_data in sparql_results.all_verbs %}
#[test]
fn test_{{ verb_data.nounName }}_{{ verb_data.verbName }}() {
    let mut cmd = Command::cargo_bin("{{ project_name }}").unwrap();
    cmd.arg("{{ verb_data.nounName }}").arg("{{ verb_data.verbName }}");

    // clap-noun-verb outputs JSON by default
    cmd.assert()
        .success()
        .stdout(predicate::str::contains("{"));
}
{% endfor %}
