Giter Site home page Giter Site logo

tutorial-tdd-quotes-api's Introduction

Tutorial - TDD Quotes API

This repo illustrates the usage of TDD to build an API dealing with Quotes.

Run the server

go run . 
# or 
go run main.go
# or build it and then run it. 
go build 
./tdd-quotes-api

Testing

# all tests
go test ./... # this could just be go test
# all tests with verbosity 
go test -v 
# all specific sub tests
 go test -run TestHandleQuotes/post -v 
# a specific sub tests
 go test -run TestHandleQuotes/post_no_body -v 

Benchmarks

go test -bench=. -run Bench

Sample from InMem store

➜  tdd-quotes-api git:(bench) ✗ go test -bench=. -run Bench                         
goos: darwin
goarch: arm64
pkg: github.com/montybeatnik/tutorials/tdd-quotes-api
BenchmarkCreateQuote-10          3380576               324.2 ns/op
PASS
ok      github.com/montybeatnik/tutorials/tdd-quotes-api        1.569s

Curl Examples

# POST
curl -X POST -d '{
    "author": "Sandi Metz",
    "message": "Design is the art of arranging code that needs to work today, and to be easy to change forever."
}' http://localhost:8000
# GET all quotes
curl -X GET http://localhost:8000
# GET a specific quote
curl -X GET http://localhost:8000/1

Postgres

export QUOTES_TEST_DSN='postgres://postgres:password@localhost:5432/quotes_db?sslmode=disable'

tutorial-tdd-quotes-api's People

Contributors

montybeatnik avatar

Watchers

 avatar

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.