Skip to content

Commit

Permalink
- allowed mapper to map body several times (#31)
Browse files Browse the repository at this point in the history
* - allowed mapper to map body several times
- removed println from logs
- made the version not print the rev if it is 0

* fixed the failing unit tests
  • Loading branch information
cjlapao committed Dec 20, 2022
1 parent 1d46f8f commit 069e0ec
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions helper/http_helper/http.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package http_helper

import (
"bytes"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -160,6 +161,7 @@ func MapRequestBody(request *http.Request, dest interface{}) error {
}

bodyArr, err := ioutil.ReadAll(request.Body)
request.Body = io.NopCloser(bytes.NewBuffer(bodyArr))
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion log/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (l *Logger) WithWarning() *Logger {
}

func (l *Logger) WithTimestamp() *Logger {
println("setting the withtimesramp")
for _, logger := range l.Loggers {
logger.UseTimestamp(true)
}
Expand Down
7 changes: 6 additions & 1 deletion version/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ func Get(v ...int) *Version {
}

func (v *Version) String() string {
return fmt.Sprint(v.Major) + "." + fmt.Sprint(v.Minor) + "." + fmt.Sprint(v.Build) + "." + fmt.Sprint(v.Rev)
if v.Rev > 0 {
return fmt.Sprint(v.Major) + "." + fmt.Sprint(v.Minor) + "." + fmt.Sprint(v.Build) + "." + fmt.Sprint(v.Rev)

} else {
return fmt.Sprint(v.Major) + "." + fmt.Sprint(v.Minor) + "." + fmt.Sprint(v.Build)
}
}

func FromString(ver string) (*Version, error) {
Expand Down
2 changes: 1 addition & 1 deletion version/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestToString(t *testing.T) {
//Assert
assert.NotNilf(t, v, "Version should not be null")
assert.Nilf(t, err, "Error should be nil")
assert.Equalf(t, "1.1.1.0", v.String(), "ToString should be equal to 1.1.1.0")
assert.Equalf(t, "1.1.1", v.String(), "ToString should be equal to 1.1.1")
}

func TestEmptyGet(t *testing.T) {
Expand Down

0 comments on commit 069e0ec

Please sign in to comment.