@wip Feature: External providers for non-image input files Calling `allmytoes` with an input files which is not a supported image type will trigger `allmytoes` to look for an “external provider” than can create a thumbnail image from the input file. The providers are managed by shell-script snippets, defined in a YAML file. `allmytoes` comes with a provider configuration inbuilt, but users can specify their own in `$XDG_CONFIG_HOME/allmytoes/provider.yaml`, or `$HOME/.config/allmytoes/provider.yaml` which will completely override the inbuilt configuration. The test scenarios in this feature definition will _not_ test the inbuilt/default provider configuration itself, but some general features for the provider feature. All scenarios are based on an SVG example. The default situation for the scenarios is a provider configuration file in `~/.config/allmytoes/provider.yaml`. Scenario: Single line command to create a thumb Given a file `.config/allmytoes/provider.yaml` with the content """ - mimes: - image/svg+xml commands: - cp "{asset-dir}/test_image_1200.png" "%(outfile)s" """ # The path is relative to the temporary directory for this scenario. # Keep in mind that the temporary scenario directory is set as $HOME in the subprocess' environment And an SVG file as input And no thumbs exist When allmytoes is started without further arguments Then the path to the large thumb is returned And the thumb is a large thumbnail of test_image_1200.png And no thumb exists for sizes other than large Scenario: Multi-line command to create a thumb Given a file `.config/allmytoes/provider.yaml` with the content """ - mimes: - image/svg+xml commands: - | ls cp "{asset-dir}/test_image_1200.png" "%(outfile)s-foo" cp "%(outfile)s-foo" "%(outfile)s" """ # The path is relative to the temporary directory for this scenario. # Keep in mind that the temporary scenario directory is set as $HOME in the subprocess' environment And an SVG file as input And no thumbs exist When allmytoes is started without further arguments Then the path to the large thumb is returned And the thumb is a large thumbnail of test_image_1200.png And no thumb exists for sizes other than large Scenario: Script exists with error Given a file `.config/allmytoes/provider.yaml` with the content """ - mimes: - image/svg+xml commands: - exit 42 """ # The path is relative to the temporary directory for this scenario. # Keep in mind that the temporary scenario directory is set as $HOME in the subprocess' environment And an SVG file as input And no thumbs exist When allmytoes is started without further arguments Then allmytoes terminates with exit code 153 Scenario: Second command not executed when first succeeds Given a file `.config/allmytoes/provider.yaml` with the content """ - mimes: - image/svg+xml commands: - touch $HOME/first && cp "{asset-dir}/test_image_1200.png" "%(outfile)s" - touch $HOME/second """ # The path is relative to the temporary directory for this scenario. # Keep in mind that the temporary scenario directory is set as $HOME in the subprocess' environment And an SVG file as input And no thumbs exist When allmytoes is started without further arguments Then the path to the large thumb is returned And the thumb is a large thumbnail of test_image_1200.png And no thumb exists for sizes other than large And the file `first` exists And the file `second` does not exist Scenario: Second command executed when first does not succeed Given a file `.config/allmytoes/provider.yaml` with the content """ - mimes: - image/svg+xml commands: - touch $HOME/first && exit 42 - touch $HOME/second && cp "{asset-dir}/test_image_1200.png" "%(outfile)s" """ # The path is relative to the temporary directory for this scenario. # Keep in mind that the temporary scenario directory is set as $HOME in the subprocess' environment And an SVG file as input And no thumbs exist When allmytoes is started without further arguments Then the path to the large thumb is returned And the thumb is a large thumbnail of test_image_1200.png And no thumb exists for sizes other than large And the file `first` exists And the file `second` exists Scenario: Script does not created image file (2nd command not executed) Given a file `.config/allmytoes/provider.yaml` with the content """ - mimes: - image/svg+xml commands: - touch $HOME/first && exit 0 - touch $HOME/second """ # The path is relative to the temporary directory for this scenario. # Keep in mind that the temporary scenario directory is set as $HOME in the subprocess' environment And an SVG file as input And no thumbs exist When allmytoes is started without further arguments Then allmytoes terminates with exit code 154 And the file `first` exists And the file `second` does not exist Scenario: Script creates invalid image file with unclear MIME type (2nd command not executed) Given a file `.config/allmytoes/provider.yaml` with the content """ - mimes: - image/svg+xml commands: - touch $HOME/first && echo "foo" > %(outfile)s && exit 0 - touch $HOME/second """ # The path is relative to the temporary directory for this scenario. # Keep in mind that the temporary scenario directory is set as $HOME in the subprocess' environment And an SVG file as input And no thumbs exist When allmytoes is started without further arguments Then allmytoes terminates with exit code 106 And the file `first` exists And the file `second` does not exist Scenario: Script creates invalid image file with unclear MIME type (2nd command not executed) Given a file `.config/allmytoes/provider.yaml` with the content """ - mimes: - image/svg+xml commands: - touch $HOME/first && echo "some HTML" > %(outfile)s && exit 0 - touch $HOME/second """ # The path is relative to the temporary directory for this scenario. # Keep in mind that the temporary scenario directory is set as $HOME in the subprocess' environment And an SVG file as input And no thumbs exist When allmytoes is started without further arguments Then allmytoes terminates with exit code 155 And the file `first` exists And the file `second` does not exist # Untested: # Scenario: Variables are handed over to script # Metas in another feature! ## Related error codes: # ToeErrorType::NoProviderForMime(_) => 150, # ToeErrorType::InvalidCommandFormatting(_) => 151, # ToeErrorType::ProviderSubprocessError(_) => 152, # ✓ ToeErrorType::ProviderHadNoSuccessfulCommand => 153, # ✓ ToeErrorType::ProviderCommandDidNotReturnExistingFile(_) => 154, # ✓ ToeErrorType::ImageFromProviderCouldNotBeLoaded(_) => 155, # ToeErrorType::CannotCreateTempDir(_) => 156, # ToeErrorType::ProviderHadNoSuccessfulMetaCommand(_) => 157, # ToeErrorType::BadMetaValue(_) => 158, # ToeErrorType::BadMetaKey(_) => 159, # ToeErrorType::ProviderSpecFileDoesNotExist(_) => 160,