bancodobrasil / stop-analyzing-api

Stop Analyzing API is the core module of Tinder like tool to help your customers make up their mind with no pain
MIT License
22 stars 17 forks source link

Create an integration test to validated the json migration flow #20

Open zamariola opened 4 years ago

zamariola commented 4 years ago

stop-analyzing-api has (currently) two possible migration scenarios: URL and Json file import.

We believe that it would be good to have an integration test using golden files to check : 1) Scenario with valid json 2) Scenario with invalid json 2.1) Format 2.2) Content 2.3) Enconding

Here is an article with details of how to create golden-files: https://ieftimov.com/post/testing-in-go-golden-files/

Here's the simplest example of a golden file test: https://github.com/zamariola/time-tracker-golang/blob/master/filesystem/filesystemsaver_integration_test.go

yurypcf commented 4 years ago

Hi! I'm currently learning Golang and I'd like to try this issue out. Can I?

tiagostutz commented 4 years ago

Hi there @yurypcf ! 👋🏻 Welcome to Stop Analyzing and thanks a lot for your help.

Absolutely. I just assigned it to you. If you need any assistance, you can freely ask here.

Can't wait for you PR! 🚀

yurypcf commented 4 years ago

Hi there @yurypcf ! 👋🏻 Welcome to Stop Analyzing and thanks a lot for your help.

Absolutely. I just assigned it to you. If you need any assistance, you can freely ask here.

Can't wait for you PR!

Okay! Nice, I'll start working on it today. Any questions I'll be posting here.

yurypcf commented 4 years ago

@tiagostutz I've been trying to setup the project and it keeps returning this error related to a package that I can't find in the projects folder (stop-analyzing-api/internal/db). What could I be doing wrong? I've already created the database and ran the migration with Prisma. image

tiagostutz commented 4 years ago

Hi @yurypcf ! I've cloned and built from scratch here and I'm having the same issue. It seems to be a problem with the Prisma generator. I'm checking it here and will come back when I have news.

Maybe @zamariola and @GreenStage could give a hand also.? Thanks!

tiagostutz commented 4 years ago

I can confirm that's kinda bug introduced in prisma-go-client v0.0.5. To reproduce run the following in the folder scripts/prisma:

$ go get github.com/prisma/prisma-client-go@v0.0.4
$ prisma-client-go generate

The output will be:

✔ Generated Prisma Client Go to ./../../internal/db/db_gen.go in 318ms

Now run the following to check that this won't work with v0.0.5:

$ go get github.com/prisma/prisma-client-go@v0.0.5
$ prisma-client-go generate

The output is blank.

So I think we should fix the Go dependency to version to v0.0.4 in go.mod and we should open an issue in the https://github.com/prisma/prisma-client-go providing those details here. Maybe someone here could even try to contribute there! That's a good Open Source Friday opportunity!

Let me know if this (kinda) workaround worked for you.

yurypcf commented 4 years ago

Worked like a charm. :) Project set up succesfully.