Sha256: 7a0a541472825d2c07a524d5f9e38158fad3e837c3658d456bb6abe8a1c27044

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

require_relative "../test_helper"

class Kloudless::LinkTest < Minitest::Test
  def test_list_links
    response = {"objects" => [{"id" => 1}]}
    Kloudless.http.expect(:get, returns: response, args: ["/accounts/1,2/storage/links", params: {active: false}]) do
      links = Kloudless::Link.list(account_ids: [1,2], active: false)
      assert_kind_of Kloudless::Collection, links
      assert_kind_of Kloudless::Link, links.first
    end
  end

  def test_create_link
    Kloudless.http.expect(:post, args: ["/accounts/1/storage/links", params: {}, data: {file_id: "file-id"}]) do
      link = Kloudless::Link.create(account_id: 1, file_id: "file-id")
      assert_kind_of Kloudless::Link, link
    end
  end

  def test_retrieve_link
    Kloudless.http.expect(:get, args: ["/accounts/1/storage/links/2", params: {active: true}]) do
      link = Kloudless::Link.retrieve(account_id: 1, link_id: 2, active: true)
      assert_kind_of Kloudless::Link, link
    end
  end

  def test_update_link
    Kloudless.http.expect(:patch, args: ["/accounts/1/storage/links/2", params: {}, data: {password: "foo"}]) do
      link = Kloudless::Link.update(account_id: 1, link_id: 2, password: "foo")
      assert_kind_of Kloudless::Link, link
    end
  end

  def test_delete_link
    Kloudless.http.expect(:delete, args: ["/accounts/1/storage/links/2", params: {}]) do
      link = Kloudless::Link.delete(account_id: 1, link_id: 2)
      assert_kind_of Kloudless::Link, link
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kloudless-1.0.1 test/kloudless/link_test.rb
kloudless-1.0.0 test/kloudless/link_test.rb