<?php

use Datalumo\PhpSdk\DataObjects\StreamResponse;
use Datalumo\PhpSdk\HttpClient;
use Datalumo\PhpSdk\Resources\CollectionResource;

beforeEach(function () {
    $this->http = Mockery::mock(HttpClient::class);
    $this->resource = new CollectionResource($this->http);
});

it('streams summarise with stream=true', function () {
    $streamResponse = Mockery::mock(StreamResponse::class);

    $this->http->shouldReceive('getStream')
        ->with('collections/col-1/summarise', ['query' => 'test', 'stream' => true])
        ->once()
        ->andReturn($streamResponse);

    $result = $this->resource->streamSummarise('col-1', ['query' => 'test']);

    expect($result)->toBe($streamResponse);
});

it('streams chat with stream=true', function () {
    $streamResponse = Mockery::mock(StreamResponse::class);

    $this->http->shouldReceive('postStream')
        ->with('collections/col-1/chat', ['message' => 'hello', 'stream' => true])
        ->once()
        ->andReturn($streamResponse);

    $result = $this->resource->streamChat('col-1', ['message' => 'hello']);

    expect($result)->toBe($streamResponse);
});
