test(xatu): simplify googletest result handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use googletest::matchers::{anything, contains, eq, err, is_true, ok};
|
||||
use googletest::{assert_that, expect_that, gtest};
|
||||
use googletest::matchers::{contains, eq, is_true};
|
||||
use googletest::{OrFail, Result as TestResult, expect_that, gtest};
|
||||
use status::Code;
|
||||
use xatu::SourceFile;
|
||||
|
||||
@@ -24,29 +24,26 @@ fn fixture_path(path: &str) -> PathBuf {
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn future_sight_reports_clean_sources_as_clean() {
|
||||
let result = xatu::future_sight(vec![fixture_source("testdata/clean.nix")]);
|
||||
assert_that!(result.as_ref(), ok(anything()));
|
||||
let report = result.unwrap();
|
||||
fn future_sight_reports_clean_sources_as_clean() -> TestResult<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/clean.nix")]).or_fail()?;
|
||||
|
||||
expect_that!(report.is_clean(), is_true());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn future_sight_rejects_parse_errors() {
|
||||
let result = xatu::future_sight(vec![fixture_source("testdata/invalid.nix")]);
|
||||
fn future_sight_rejects_parse_errors() -> TestResult<()> {
|
||||
let error = xatu::future_sight(vec![fixture_source("testdata/invalid.nix")])
|
||||
.err()
|
||||
.or_fail()?;
|
||||
|
||||
expect_that!(result.as_ref(), err(anything()));
|
||||
if let Err(error) = result {
|
||||
expect_that!(error.code(), eq(Code::FailedPrecondition));
|
||||
}
|
||||
expect_that!(error.code(), eq(Code::FailedPrecondition));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn future_sight_reports_deprecated_to_path_qualified_findings() {
|
||||
let result = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")]);
|
||||
assert_that!(result.as_ref(), ok(anything()));
|
||||
let report = result.unwrap();
|
||||
fn future_sight_reports_deprecated_to_path_qualified_findings() -> TestResult<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")]).or_fail()?;
|
||||
|
||||
let findings = report
|
||||
.diagnostics
|
||||
@@ -65,13 +62,12 @@ fn future_sight_reports_deprecated_to_path_qualified_findings() {
|
||||
"deprecated_to_path"
|
||||
)))
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn future_sight_reports_deprecated_to_path_unqualified_findings() {
|
||||
let result = xatu::future_sight(vec![fixture_source("testdata/lint_variants.nix")]);
|
||||
assert_that!(result.as_ref(), ok(anything()));
|
||||
let report = result.unwrap();
|
||||
fn future_sight_reports_deprecated_to_path_unqualified_findings() -> TestResult<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_variants.nix")]).or_fail()?;
|
||||
|
||||
let findings = report
|
||||
.diagnostics
|
||||
@@ -90,13 +86,12 @@ fn future_sight_reports_deprecated_to_path_unqualified_findings() {
|
||||
"deprecated_to_path"
|
||||
)))
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn future_sight_reports_empty_inherit_findings() {
|
||||
let result = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")]);
|
||||
assert_that!(result.as_ref(), ok(anything()));
|
||||
let report = result.unwrap();
|
||||
fn future_sight_reports_empty_inherit_findings() -> TestResult<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")]).or_fail()?;
|
||||
|
||||
let findings = report
|
||||
.diagnostics
|
||||
@@ -115,4 +110,5 @@ fn future_sight_reports_empty_inherit_findings() {
|
||||
"empty_inherit"
|
||||
)))
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user