# Test setup
###### tags: `Research` `Test` `Unit` `Smoke`
## :memo: Links
Starging with reference links fot the task
- [mongoose test guide](https://medium.com/@eminetto/data-migration-with-golang-and-mongodb-d2930e7f3b8ahttps://codeutopia.net/blog/2016/06/10/mongoose-models-and-unit-tests-the-definitive-guide/)
- [mongoose connection test](https://github.com/Automattic/mongoose/issues/2280)
- [socket io test guide](http://47.92.1.61/blog/testing-socket-io-server-nodejs-with-mocha/)
- [express tests](https://alexanderpaterson.com/posts/how-to-start-unit-testing-your-express-apps)
## Testing
single file test
watch mode
coverage report
I choosed the make script, a commom way to use commands, of interpreted or compiled codes.
```
make migrate new description-of-migration
make migrate up
make migrate down
```
Migration is a operation to production and develpment enviroments, but for enviroment is need of specific type of migration, the seeds.
```
make seed new description-of-seed
make seed up
make seed down
```
For use this I have looked into the following link:
- [passing arguments to make run in Stackoverflow](https://stackoverflow.com/questions/2214575/passing-arguments-to-make-run)
## Scripts
### drop collection
```go
db.C("projects").coll.DropCollection()
```
:::info
:book: Reference:
:::
### create collection
```go
db.Run(bson.D{{Name: "create", Value: "projects"}}, nil)
```
:::info
:book: Reference:
:::
### insert data
```go
db.C("projects").Insert(bson.M{
"name": "plando-development",
"endDate": "2020-05-30T00:00:00.000+00:00",
})
```
:::info
:book: Reference:
:::
### remove data
```go
db.C("projects").Remove(bson.M{
"name": "plando-development",
})
```
:::info
:book: Reference:
:::
`bson.M` is a Map type from bson, the mongodb type model.
## Automation
links:
- [docker compose with command after run](https://github.com/docker/compose/issues/1809)