#!perl
use Cassandane::Tiny;

sub test_mailbox_set_destroy_twice
    :min_version_3_8
{
    my ($self) = @_;

    my $jmap = $self->{jmap};

    xlog $self, "create mailbox";
    my $res = $jmap->CallMethods([
            ['Mailbox/set', { create => { "1" => {
                            name => "foo",
                            role => undef
             }}}, "R1"]
    ]);
    my $id = $res->[0][1]{created}{"1"}{id};

    xlog $self, "destroy mailbox";
    $res = $jmap->CallMethods([
            ['Mailbox/set', { destroy => [ $id ] }, "R1"]
    ]);
    $self->assert_str_equals($id, $res->[0][1]{destroyed}[0]);

    xlog $self, "destroy mailbox";
    $res = $jmap->CallMethods([
            ['Mailbox/set', { destroy => [ $id ] }, "R1"]
    ]);
    $self->assert_str_equals("notFound", $res->[0][1]{notDestroyed}{$id}{type});
}
