Sha256: b5924b957257ea4f30ee552a9bf308a291696fc65f1ab8c593f713ea6ca8b750
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
# frozen_string_literal: true require File.expand_path("spec_helper", __dir__) module Gitlab class Pipeline def ==(other) id == other.id && created_at == other.created_at && status = other.status end end describe Client do before do @client = Gitlab::Client.new({ auth_token: "token-token-token", endpoint: "gitlab.com" }) end it "Filters non running pipelines" do pipelines = [{ id: 1, status: "running", created_at: "2020-05-12T10:45:30.720Z" }, { id: 2, status: "failed", created_at: "2020-05-12T11:45:30.720Z" }, { id: 3, status: "finished", created_at: "2020-05-12T12:45:30.720Z" }] .map { |p| Gitlab::ObjectifiedHash.new(p) } allow_any_instance_of(Gitlab::Client).to receive(:merge_request_pipelines).with(346, 549).and_return(pipelines) expect(@client.running_pipelines_for_mr(346, 549)).to eq([Gitlab::Pipeline.new(1, "running", DateTime.parse("2020-05-12T10:45:30.720Z"))]) end it "Parses pipelines into ::Pipeline" do raw_pipelines = [{ id: 1, status: "running", created_at: "2020-05-12T10:45:30.720Z" }, { id: 2, status: "running", created_at: "2020-05-12T11:45:30.720Z" }, { id: 3, status: "running", created_at: "2020-05-12T12:45:30.720Z" }] gitlab_pipelines = raw_pipelines.map { |p| Gitlab::ObjectifiedHash.new(p) } parsed_pipelines = raw_pipelines.map { |p| Gitlab::Pipeline.new(p[:id], p[:status], DateTime.parse(p[:created_at])) } allow_any_instance_of(Gitlab::Client).to receive(:merge_request_pipelines).with(346, 549).and_return(gitlab_pipelines) @client = Gitlab::Client.new({ auth_token: "token-token-token", endpoint: "gitlab.com" }) expect(@client.running_pipelines_for_mr(346, 549)).to match_array(parsed_pipelines) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
danger-gitlab_cancelbot-1.0.1 | spec/gitlab_spec.rb |
danger-gitlab_cancelbot-1.0.0 | spec/gitlab_spec.rb |