Code Monkey home page Code Monkey logo

Comments (3)

parroty avatar parroty commented on July 24, 2024

Thanks for the report and sorry being late to check.

I'm running the test in your repository (https://github.com/weppos/dnsimple-elixir on branch test-create) and I can see the following 2 errors.

  1) test .create_domains returns a Dnsimple.Response (DnsimpleDomainsServiceTest)
     test/dnsimple_domains_service_test.exs:39
     ** (ExVCR.InvalidRequestError) response for [URL:https://api.dnsimple.test/v2/1010/domains, METHOD:post] was not found
     stacktrace:
       lib/exvcr/handler.ex:28: ExVCR.Handler.get_response_from_cache/2
       lib/exvcr/handler.ex:13: ExVCR.Handler.get_response/2
       (hackney) :hackney.request(:post, "https://api.dnsimple.test/v2/1010/domains", [{"Accept", "application/json"}, {"User-Agent", "dnsimple-elixir/0.0.1"}, {"Authorization", "Bearer i-am-a-token"}], "", [])
       (httpoison) lib/httpoison/base.ex:396: HTTPoison.Base.request/9
       (httpoison) lib/httpoison.ex:66: HTTPoison.request!/5
       (dnsimple) lib/dnsimple.ex:123: Dnsimple.Client.execute/6
       (dnsimple) lib/dnsimple/domains_service.ex:32: Dnsimple.DomainsService.create_domain/5
       test/dnsimple_domains_service_test.exs:42

.....

  2) test .create_domain builds the correct request (DnsimpleDomainsServiceTest)
     test/dnsimple_domains_service_test.exs:32
     ** (ExVCR.InvalidRequestError) response for [URL:https://api.dnsimple.test/v2/1010/domains, METHOD:post] was not found
     stacktrace:
       lib/exvcr/handler.ex:28: ExVCR.Handler.get_response_from_cache/2
       lib/exvcr/handler.ex:13: ExVCR.Handler.get_response/2
       (hackney) :hackney.request(:post, "https://api.dnsimple.test/v2/1010/domains", [{"Content-Type", "application/json"}, {"Accept", "application/json"}, {"User-Agent", "dnsimple-elixir/0.0.1"}, {"Authorization", "Bearer i-am-a-token"}], "{\"name\":\"example.com\"}", [])
       (httpoison) lib/httpoison/base.ex:396: HTTPoison.Base.request/9
       (httpoison) lib/httpoison.ex:66: HTTPoison.request!/5
       (dnsimple) lib/dnsimple.ex:123: Dnsimple.Client.execute/6
       (dnsimple) lib/dnsimple/domains_service.ex:32:

It seems the @service.create_domain is running post request, and it's mismatched with the request parameters. Updating as follows make sense for you?

--- a/test/dnsimple_domains_service_test.exs
+++ b/test/dnsimple_domains_service_test.exs
@@ -30,14 +30,14 @@ defmodule DnsimpleDomainsServiceTest do


   test ".create_domain builds the correct request" do
-    fixture = ExvcrUtils.response_fixture("createDomain/created.http", [method: "delete", url: @client.base_url <> "/v2/1010/domains", request_body: ~s'{"name":"example.com"}'])
+    fixture = ExvcrUtils.response_fixture("createDomain/created.http", [method: "post", url: @client.base_url <> "/v2/1010/domains", request_body: ~s'{"name":"example.com"}'])
     use_cassette :stub, fixture do
       @service.create_domain(@client, "1010", %{ name: "example.com" })
     end
   end

   test ".create_domains returns a Dnsimple.Response" do
-    fixture = ExvcrUtils.response_fixture("createDomain/created.http", [url: "~r/\/v2/$", request_body: ""])
+    fixture = ExvcrUtils.response_fixture("createDomain/created.http", [method: "post", url: "~r/\/v2/$", request_body: ""])
     use_cassette :stub, fixture do
       { :ok, response } = @service.create_domain(@client, "1010", "")
       assert response.__struct__ == Dnsimple.Response

The following part sounds valid, and I'm thinking to update as you suggested.

I suggest to remove options[:stub] != nil and just run the match when an explicit request_body parameter is set.

from exvcr.

weppos avatar weppos commented on July 24, 2024

Oh, wow, that's embarrassing. I can't believe I was using a delete instead of a post. 😓

The following part sounds valid, and I'm thinking to update as you suggested.

That would be awesome! Thanks for your follow up.

from exvcr.

parroty avatar parroty commented on July 24, 2024

Thanks for the quick checking. Regarding the fix part, please allow some time to merge to master looking for good timing.

from exvcr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.