Commit a7b47b50 authored by Stan Hu's avatar Stan Hu

Fix flaky test in cluster_agents_spec.rb

Two of the three tokens had `nil` `last_used_at` dates, and the database
can return those in any order. To fix the spec, we assign one of the
`nil` values a date. The order also needs to be sorted most recently
used, with `nil` at the end.
parent ed19a0bd
......@@ -51,7 +51,7 @@ RSpec.describe 'Project.cluster_agents' do
context 'selecting tokens' do
let_it_be(:token_1) { create(:cluster_agent_token, agent: agents.first) }
let_it_be(:token_2) { create(:cluster_agent_token, agent: agents.second) }
let_it_be(:token_2) { create(:cluster_agent_token, agent: agents.second, last_used_at: 3.days.ago) }
let_it_be(:token_3) { create(:cluster_agent_token, agent: agents.second, last_used_at: 2.days.ago) }
let(:cluster_agents_fields) { [:id, query_nodes(:tokens, of: 'ClusterAgentToken')] }
......@@ -62,9 +62,9 @@ RSpec.describe 'Project.cluster_agents' do
tokens = graphql_data_at(:project, :cluster_agents, :nodes, :tokens, :nodes)
expect(tokens).to match([
a_hash_including('id' => global_id_of(token_1)),
a_hash_including('id' => global_id_of(token_3)),
a_hash_including('id' => global_id_of(token_2))
a_hash_including('id' => global_id_of(token_2)),
a_hash_including('id' => global_id_of(token_1))
])
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment