brianfoshee / aquaponics-data

0 stars 0 forks source link

WIP - organizing code and writing tests #11

Closed brianfoshee closed 9 years ago

brianfoshee commented 9 years ago

This PR now does a few things beyond what it was originally opened for:

Things it needs:

Original commit message:

This isn't ready to merge yet (needs testing) but is to remove a 3rd party dependency. the sqlx.Select() function is handy, but using the database/sql package in the stdlib doesn't add any complexity, just some verbosity during the Next() and Scan() actions (these lines https://github.com/crakalakin/aquaponics-data/blob/remove-sqlx/main.go#L59-L76).

After finally understanding the next/scan functions from watching http://www.confreaks.com/videos/3440-gophercon2014-building-database-applications-with-database-sql, I decided this would be a good thing to try.

brianfoshee commented 9 years ago

@letsgitgrowing let me know what you think of the direction of this branch or if you have any questions. Read the updated message above (it originally was not as broad in scope).

nathanprayzo commented 9 years ago

Reviewing branch now.

brianfoshee commented 9 years ago

A handy tip: Instead of needing to cd into each package's directory to run tests, lint, and vet, add ./... to each command's args from the project's root directory and the command will run for each directory which has a package in it. go test ./... go vet ./... golint ./...

brianfoshee commented 9 years ago

@letsgitgrowing the test for GetReadings() look good. I wouldn't worry about testing JSON marshaling in there, though. We can test that in the http handler tests.

Also, let's verify at some point that this issue in the postgres driver package isn't a problem with our inserting a timestamp without timezone column type. The code for that whole repository is an interesting read.

brianfoshee commented 9 years ago

Before this gets squashed/merged let's run go vet, golint and go fmt on all files.

nathanprayzo commented 9 years ago

Whoops, forgot about those tools :)

brianfoshee commented 9 years ago

I just updated the vim-go plugin to the latest version, and it'll now run the goimports tool if you set let g:go_fmt_command = "goimports" in your .vimrc. So it'll run both gofmt on saving a file to format the code, and then it'll import any packages that you need (or remove the ones you're not using).

Did you have any luck with that windows terminal emulator?