Skip to content

It's a learn project based on my tech test in Americanas S.A.

License

Notifications You must be signed in to change notification settings

EddieSCJ/starwars-api-go

Repository files navigation

👾 Go Star Wars API 👾

Project Tooling

Description

This api is a simple wrapper for the Star Wars API where you can get information about the characters, planets, starships, vehicles, species, films, and more with a few extra features where you can handle this data however you need.

Please, read the content below to know how to use this api and if is there any doubt, please, contact me.

Using Cloud Tools

  • Snyk
    • Just click in the link above and search for starwars-api-go, so you will be able to see the security problems.
  • SonarCloud
    • Clicking the link above you will be redirected to the quality analysis of this project.
  • CodeCov
    • You can click the link above and see the code coverage details by commit or any type of data or just see the summary in your PR.
  • GolangCI-Lint
    • You are able to see it in the actions tab, most specifically in the Lint Check job.

Running

To run the program you just need to type: go run main.go in your terminal and wait to see magic happens. However, make sure you have a mongodb instance in Docker or locally running to the app uses.

Moreover, there is some enviroment variables you can use, follow:

NAME VALUE
MONGO_HOST localhost
MONGO_USER
MONGO_PASSWORD
MONGO_PORT 27017
MONGO_DB development
MONGO_CONTAINER_NAME mongoservice
SWAPI_URL https://swapi.dev/api
ENV dev
API_PORT 8080

Testing

There are two types of tests which are used in this project, unit and integrated tests. To run the unit tests you just need to type: go test ./... in your terminal and wait to see magic happens.

However, our integrated tests are running with DockerTest to reproduce more realistic scenarios, so, we need some extra commands, nothing scaring, firstly, make sure you have Docker installed in your machine and type go test -p 1 -tags integration ./... in your terminal.

If you want to see the benchmarks, just run go test ./... -bench .

❔ What exactly is this -p 1

The Go Programming language run the test packages in parallel, so, it's possible our docker containers being not ready before some integrations test. To make sure it will not happen, we limit the workers to only one.

About

It's a learn project based on my tech test in Americanas S.A.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published