https://github.com/fajarcandraaa/simple-golang-unit-testing
Simple Golang Unit Testing
https://github.com/fajarcandraaa/simple-golang-unit-testing
backend backenddeveloper go golang unit-testing
Last synced: 15 days ago
JSON representation
Simple Golang Unit Testing
- Host: GitHub
- URL: https://github.com/fajarcandraaa/simple-golang-unit-testing
- Owner: fajarcandraaa
- Created: 2023-03-01T14:10:41.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T15:55:51.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T03:39:27.498Z (over 1 year ago)
- Topics: backend, backenddeveloper, go, golang, unit-testing
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Golang Unit Testing

We will learn about implement unit testing in Golang.
## Topics :
- Setting up the Golang Project
- Defining the Product Entity
- Connecting to the database
- Implementing Unit test with 1 feature, it's find data by ID
## Our Step :
- In the first step, we create an entities to represent the structure of our data in the entity package
- In the second step, we create query a function to handle our query
- Then register the new function in our model interface
- In the third step, we create algorithm function to handle all condition in our flow proccess
- and again, we register it into source contract interface
- In fourth step is create faker data or mock data
- than, we create a seederes, to input fake data to database testing
- And the last step is, we create unit test with 2 case, 1 positive cae and 1 negative case
## Notes :
Last but not least, let's start to try to write a function that we think will be used many times in helpers.
Happy coding and keep learning 😜