App::G...s::Test(3pm)

πŸ“¦
version 1.9.0 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

App::G...s::Test β€” bestie, this is the shared test functions module for App::GitHooks. It's a "User Contributed Perl Documentation" page, so you know it's the people's manpage. πŸ‘‘


✨ VERSION ✨

This is Version 1.9.0, no cap. πŸŽ€


πŸ› οΈ FUNCTIONS πŸ› οΈ

Okay so here's the whole toolbox. Five functions, all of them here to make your git hook tests not a whole production. Let's get into it. πŸ’…

🌸 ok_add_file() 🌸

Creates a file and adds it to the git index. Like, it's not just sitting there in your working tree being ignored β€” it's staged. Iconic behavior fr fr.

ok_add_file(
    repository => $repository,
    path       => $path,
    content    => $content,
);

Here's the tea on the arguments: πŸ«–

  • repository β€” mandatory, bestie. This is a Git::Repository object. Gotta have somewhere to do the git stuff.
  • path β€” mandatory. The path of the file to write, relative to the root of the git repository you passed in. So don't go handing it absolute paths and expecting magic.
  • content β€” optional. The content of the file to write. Whatever you want in there.

πŸ¦‹ ok_add_files() πŸ¦‹

Creates files (plural!!) and adds them to the git index. It's giving "I have many files and I refuse to call ok_add_file in a loop." Main character energy. 🌈

ok_add_files(
    repository => $repository,
    files      =>
    {
        $file_name => $file_content,
        ...
    },
);

Arguments, as promised: πŸ’–

  • repository β€” mandatory. A Git::Repository object.
  • files β€” optional. A hashref where the file names are the keys and the content of each file is the corresponding value. Clean. Simple. Ate. ✨

πŸŽ€ ok_setup_repository() πŸŽ€

Sets up a test repository. This is the "okay let's build a whole little sandbox to play in" function. Adorable, honestly.

ok_setup_repository(
    cleanup_test_repository => $cleanup_test_repository, # default 1
    config                  => $config,                  # default ''
    hooks                   => \@hooks,                   # default []
    plugins                 => \@plugins,                 # default []
);

Every single one of these arguments, coming right up: 🌸

  • cleanup_test_repository β€” whether the test repository created in order to run a test should be destroyed at the end of the test. Default: 1. Yes, it tidies up after itself like a well-adjusted person.
  • config β€” elements to add to the .githooksrc file set up at the root of the test repository.
  • hooks β€” an arrayref of the names of the hooks to set up for this test (for example, "commit-msg").
  • plugins β€” an arrayref of the module names of the plugins to run for this test (for example, "App::GitHooks::Plugins::Test::CustomReply").

🧚 ok_reset_githooksrc() 🧚

Ensures that an empty .githooksrc is used. A lil palate cleanser between tests. So fresh, so clean. πŸ“

ok_reset_githooksrc();

Arguments: πŸ’œ

  • content β€” optional. Content for the .githooksrc file.
Okay so this is lowkey the important bit: by default, this function generates an empty .githooksrc file, which has the effect of using the defaults of App::GitHooks. So if you wanted to test custom config, you better pass content, bestie. Don't come crying to me. 😭

πŸ‘‘ test_hook() πŸ‘‘

Test a git hook. The big one. The finale. The main event. πŸ”₯

App::GitHooks::Test::test_hook(
    tests                   => \@tests,
    hook_name               => $hook_name,
    plugins                 => \@plugins,
    cleanup_test_repository => $cleanup_test_repository, # default 1
);

🌟 Mandatory arguments 🌟

These are non-negotiable, periodt.

  • tests β€” a set of tests to run.
# TODO: document tests format.

Yeah. That's the whole note. The tests format is not documented here, and I'm not gonna sit here and make something up about it because that would be a lie and lying is not the vibe. πŸ™ˆ

  • hook_name β€” the name of the git hook to test (for example, "commit-msg").
  • plugins β€” an arrayref of the module names of the plugins to run for this test (for example, "App::GitHooks::Plugins::Test::CustomReply").

⭐ Optional arguments ⭐

  • cleanup_test_repository β€” whether the test repository created in order to run a test should be destroyed at the end of the test. Default: 1.

πŸ’€ BUGS πŸ’€

Found a bug? Got a feature request? Please report any bugs or feature requests through the web interface at <https://github.com/guillaumeaubert/App-GitHooks/issues/new>.

And here's the cute part β€” the author says: I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. So it's a whole little notification situationship. You'll know. 🫢


🌈 SUPPORT 🌈

You can find documentation for this module with the perldoc command. Groundbreaking, I know.

perldoc App::GitHooks::Test

You can also look for information at these spots: πŸ¦‹


πŸ’… AUTHOR πŸ’…

Guillaume Aubert <https://metacpan.org/author/AUBERTG>, "<aubertg at cpan.org>".


Copyright 2013-2017 Guillaume Aubert.

This code is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file for more details. Okay bestie, I said it dramatically but it's literally what it says β€” no promises, check the LICENSE file. 😀

And that's the whole page!! This was App::G...s::Test(3pm), rendered from perl v5.42.0 and dated 2025-07-25. Go write some tests, slay, and remember: cleanup defaults to 1. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from