-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Labels
Description
Problem
It is often happened in tests that we need to read data from __DATA__ section.
use Mojo::Loader qw/ data_section /;
my $user = 'user';
my $data = eval data_section 'main', "create";
$t->post_ok('/multidata', json => $data )->status_is( 200 )->or( \&diag_msg );
__DATA__
@@ create
hello $user
@@ section2
xxxx
It would be nice to have this functionality by default.
Solution
Implement plugin to read data section like https://metacpan.org/pod/Data::Section::Simple or https://metacpan.org/pod/Data::Section or https://docs.mojolicious.org/Mojo/Loader#data_section. Mojo solution looks most simple. Thus preferable.
use Test2::V0;
my $data = read_data 'section2';
my $user = 'zzzz';
my $hi = eval read_data 'create';
__DATA__
@@ create
hello $user
@@ section2
xxxx