#!perl
use Cassandane::Tiny;

sub test_blob_upload_basic_legacy
    :needs_component_jmap :JMAPExtensions
{
    my $self = shift;
    my $instance = $self->{instance};

    xlog "Test without capability";
    my $jmap = $self->{jmap};
    my $res = $jmap->CallMethods([['Blob/upload', { create => { b1 => { data => [{'data:asText' => 'hello world'}] } } }, 'R1']]);
    $self->assert_str_equals($res->[0][0], 'error');

    $jmap->AddUsing('https://cyrusimap.org/ns/jmap/blob');

    xlog "Regular Blob/upload works and returns a blobId";
    $res = $jmap->CallMethods([['Blob/upload', { create => { b1 => { data => [{'data:asText' => 'hello world'}] } } }, 'R1']]);
    $self->assert_str_equals('Blob/upload', $res->[0][0]);
    $self->assert_not_null($res->[0][1]{created}{b1}{id});
}
