Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task tests can fail if first task in instance is a snapshotCreate #611

Closed
ellnix opened this issue Mar 8, 2025 · 0 comments · Fixed by #610
Closed

Task tests can fail if first task in instance is a snapshotCreate #611

ellnix opened this issue Mar 8, 2025 · 0 comments · Fixed by #610
Labels
maintenance Anything related to maintenance (CI, tests, refactoring...)

Comments

@ellnix
Copy link
Collaborator

ellnix commented Mar 8, 2025

This test:

  let(:succeeded_task_keys) { [*enqueued_task_keys, 'details', 'duration', 'startedAt', 'finishedAt'] }

  it 'gets a task of the Meilisearch instance' do
    task = client.task(0)

    expect(task).to be_a(Hash)
    expect(task['uid']).to eq(0)
    expect(task.keys).to include(*succeeded_task_keys)
  end

expects succeeded task (specifically task 0) to have the details key, which is not present on snapshotCreate tasks, causing the test to fail until something happens to change what task 0 is (starting a new clean meilisearch instance). See related issue: meilisearch/documentation#3177

Reproduction:

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"
  gem 'minitest', '~> 5.25', '>= 5.25.4'

  gem 'meilisearch', ENV["MEILISEARCH_RUBY_VERSION"] || "~> 0.31.0"
  # If you want to test against changes that have been not released yet
  # gem "meilisearch", github: "meilisearch/meilisearch-ruby", branch: "main"

  # Open a debugging session with the `debugger` method
  # gem 'debug'
end

require 'minitest/autorun'

URL = format('http://%<host>s:%<port>s',
             host: ENV.fetch('MEILISEARCH_URL', 'localhost'), port: ENV.fetch('MEILISEARCH_PORT', '7700'))

$client = Meilisearch::Client.new(URL, 'masterKey', { timeout: 2, max_retries: 1 })

class BugTest < Minitest::Test
  def test_snapshot_missing_details
    $client.create_snapshot

    task = $client.task(0)
    assert task.key?("details")
  end
end
@ellnix ellnix added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Mar 8, 2025
@meili-bors meili-bors bot closed this as completed in 1833a9c Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Anything related to maintenance (CI, tests, refactoring...)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant