diff --git a/.dockerignore b/.dockerignore index 48e67b0..32c9036 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,4 @@ bin/ *.hurl .git/ .jj/ +.direnv/ diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index ee961c0..f040bba 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,4 @@ go.work # End of https://www.toptal.com/developers/gitignore/api/go -*.hurl +.direnv/ diff --git a/README.org b/README.org index cf91abf..86a67ac 100644 --- a/README.org +++ b/README.org @@ -7,18 +7,24 @@ - [[https://hurl.dev][hurl]] :: CLI tool that runs http requests, similar to curl - [[https://docs.docker.com/desktop/][docker :: ]] Using docker to run project and mocks +- [[https://just.systems/][just]] :: CLI runner - [[https://jqlang.org/][jq]] :: (Optional) CLI tool to query JSON data +If you're using nix, you can find a flake in the root of the project and run =nix develop= to download all the tools (or allow [[https://direnv.net/][direnv]] to auto import in your path) + *** Usage -Run the project with both providers mocked: +Run docker compose to start mocks, the mocks will use ports =8002= and =8003= and the were created using [[https://github.com/mrak/stubby4node][stubby4node]] #+begin_src shell docker compose up #+end_src -The docker compose file is configured to build and run 3 dockers, 2 being the mocked providers (Stripe and Braintree), they're both were created using [[https://github.com/mrak/stubby4node][stubby4node]] and the project. -The main project will use port =8000= in your machine and the providers will use port =8001= and =8002= (this is mostly for running the main project outside docker). +In another terminal, bulid and run the project with =just=, it will start the project in port =8000= + +#+begin_src shell +just run +#+end_src In other terminal, make the request with hurl @@ -31,3 +37,11 @@ In case you want to see the response with json format, you can use jq #+begin_src shell hurl request.hurl | jq . #+end_src + +** Tests + +To run all tests, you can run the command that it will run all tests from the project: + +#+begin_src shell +just test +#+end_src diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bc10f12 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1752012998, + "narHash": "sha256-Q82Ms+FQmgOBkdoSVm+FBpuFoeUAffNerR5yVV7SgT8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2a2130494ad647f953593c4e84ea4df839fbd68c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..aadff9b --- /dev/null +++ b/flake.nix @@ -0,0 +1,28 @@ +{ + description = "A Nix-flake-based Golang development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + inherit (pkgs.lib) optional optionals; + + pkgs = import nixpkgs { inherit system; }; + in + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + go + hurl + just + jq + ]; + }; + } + ); +} diff --git a/request.hurl b/request.hurl index b98cc6f..d39d9bd 100644 --- a/request.hurl +++ b/request.hurl @@ -13,3 +13,4 @@ Content-Type: application/json "installments": 1 } } +HTTP 200