Skip to content

Commit

Permalink
tests: Add supporting test coverage
Browse files Browse the repository at this point in the history
Logic: snapshot releases are allowed to omit the `date` attribute.
  • Loading branch information
jayaddison committed Aug 18, 2024
1 parent 9501ce0 commit cc0aef8
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test-validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,46 @@ test_validator_manyerrors_desktopapp (void)
g_assert_false (ret);
}

/**
* test_validator_snapshot_release:
*
* Allow snapshot releases to omit a release date.
*/
static void
test_validator_snapshot_release (void)
{
gboolean ret;
g_autoptr(GList) issues = NULL;
g_autoptr(AsValidator) validator = as_validator_new ();

const gchar *SAMPLE_XML = "<component>\n"
" <id>org.example.test</id>\n"
" <metadata_license>FSFAP</metadata_license>\n"
" <project_license>LGPL-2.1+</project_license>\n"
" <name>Test</name>\n"
" <summary>Another sample unittest</summary>\n"
" <releases>\n"
" <release type=\"snapshot\" version=\"1.0-rc1\"/>\n"
" <release type=\"stable\" date=\"2024-08-15\" version=\"0.9\"/>\n"
" </releases>\n"
"</component>\n";

AsVResultCheck expected_results[] = {
{
"developer-info-missing", "",
-1,
AS_ISSUE_SEVERITY_INFO, },

{ NULL, NULL, 0, AS_ISSUE_SEVERITY_UNKNOWN }
};

ret = as_validator_validate_data (validator, SAMPLE_XML);

issues = as_validator_get_issues (validator);
_astest_check_validate_issues (issues, (AsVResultCheck *) &expected_results);
g_assert_true (ret);
}

/**
* test_validator_relationissues:
*
Expand Down Expand Up @@ -435,6 +475,7 @@ main (int argc, char **argv)
test_validator_manyerrors_desktopapp);
g_test_add_func ("/AppStream/Validate/RelationIssues", test_validator_relationissues);
g_test_add_func ("/AppStream/Validate/Overrides", test_validator_overrides);
g_test_add_func ("/AppStream/Validate/Snapshot", test_validator_snapshot_release);

ret = g_test_run ();
g_free (datadir);
Expand Down

0 comments on commit cc0aef8

Please sign in to comment.