RFC for testing package design
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- elixir
- Ambito
- testing-qa
Direzione di ricerca
Inizia leggendo l’issue correlata all’indirizzo https://github.com/code-corps/stripity-stripe/issues/124 e la configurazione ExUnit proposta in questa issue. Valuta gli entry point Stripe.Test.Server.start/stop e Stripe.Test.Customer.create insieme alle note sull’isolamento di ETS e Plug. Il lavoro è completato quando si raggiunge un accordo sul design del pacchetto di test e sul suo ambito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
We should discuss what this should look like.
Here are some notes from https://github.com/code-corps/stripity-stripe/issues/124
The test package can distribute a lightweight replica of the Stripe service. That way, testing can be done something like the following:
test "retrieves all plans where the storage limit is greater than 30" do
Stripe.Test.create(:plan, 10)
Stripe.Test.create(:plan, 10, metadata: [storage_limit: 10])
Stripe.Test.create(:plan, 10, metadata: [storage_limit: 35])
Stripe.Test.create(:plan, 10, metadata: [storage_limit: 30])
# This is business logic that will call the StripityStripe module
plans = MyApp.Module.get_plans(:gt, 30)
assert Enum.count(plans) == 10
end
The data can be stored on a per-test basis in ETS, allowing users to build up the necessary state and tear it down without needing to know the intricacies of the system.
For example:
defmodule Stripe.CustomerTest do
# this may be able to be true
use ExUnit.Case, async: false
# Most of this setup process can be abstracted into the library, but putting
# it here so that others understand
setup do
# Starts a separate process
# - That process loads a Plug responder that binds to an available port
# - It also seeds an ETS table that it claims ownership of
# - The ETS table and Plug responder are bound to this specific test,
# so they are isolated to this test and any state manipulation on them
# will not affect other tests
# - Returns a struct of some form like %Stripe.Test.Server{port: 4515, pid: #PID<0.35.0>}
{:ok, stripe_server} = Stripe.Test.Server.start()
Application.put_env(:stripity_stripe, :api_base_url, "http://localhost:#{stripe_server.port}")
on_exit fn ->
# Cleans up the ETS table and stops the plug responder and owning process
Stripe.Test.Server.stop(stripe_server)
end
{:ok, stripe: stripe_server}
end
describe "Stripe.Customer.retrieve/1" do
test "retrieves a customer by ID", %{stripe: stripe} do
# Uses the Stripe.Test.Customer module to create a new customer in the
# ETS backed server (essentially, this is a factory method)
%{id: id} = Stripe.Test.Customer.create(stripe)
# Makes an actual API request from the high level API through the low level
# API and through the OS network stack
{:ok, customer} = Stripe.Customer.retrieve(id)
assert customer.id == id
end
end
end
- Lingua principale
- Elixir
- Stelle
- 1
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hexlet-codebattle/codebattle#2362 ·
-
Remove agent guidance that restates what the code showsForse già presa @zorn l’ha presa 1 giorno fa. Apertadocumentation low-priority
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
intellij-elixir/intellij-elixir#4501 ·
I maintainer di solito rispondono entro 1 giorno
-
Database text with `$` generates invalid `d2` outputForse già presa @halostatue l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100