Skip to content

Commit

Permalink
fix wording for weight
Browse files Browse the repository at this point in the history
  • Loading branch information
zupzup committed Dec 30, 2022
1 parent 9ac70e2 commit 6545fb5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions renderer/json.go
Expand Up @@ -3,9 +3,10 @@ package renderer
import (
"encoding/json"
"fmt"
"time"

"github.com/zupzup/calories/model"
"github.com/zupzup/calories/util"
"time"
)

type success struct {
Expand Down Expand Up @@ -59,7 +60,7 @@ func (r *JSONRenderer) WeightHistory(weights []model.Weight, config *model.Confi
func (r *JSONRenderer) AddWeight(weight float64, config *model.Config) (string, error) {
res := success{
Success: true,
Message: fmt.Sprintf("Added weight: %s", util.WeightUnit(config.UnitSystem, weight)),
Message: fmt.Sprintf("Set weight: %s", util.WeightUnit(config.UnitSystem, weight)),
}
b, err := json.Marshal(res)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions renderer/json_test.go
Expand Up @@ -3,10 +3,11 @@ package renderer
import (
"errors"
"fmt"
"github.com/zupzup/calories/model"
"github.com/zupzup/calories/util"
"testing"
"time"

"github.com/zupzup/calories/model"
"github.com/zupzup/calories/util"
)

func TestJSONError(t *testing.T) {
Expand Down Expand Up @@ -56,7 +57,7 @@ func TestJSONConfig(t *testing.T) {
func TestJSONAddWeight(t *testing.T) {
r := JSONRenderer{}
res, err := r.AddWeight(85.0, &model.Config{})
expectedString := "Added weight: 85.0 kg"
expectedString := "Set weight: 85.0 kg"
expected := fmt.Sprintf("{\"success\":true,\"message\":\"%s\"}", expectedString)
if res != expected || err != nil {
t.Errorf("Error, actual: %v expected: %v", res, expected)
Expand Down
5 changes: 3 additions & 2 deletions renderer/terminal.go
Expand Up @@ -2,10 +2,11 @@ package renderer

import (
"fmt"
"time"

"github.com/fatih/color"
"github.com/zupzup/calories/model"
"github.com/zupzup/calories/util"
"time"
)

// TerminalRenderer is the renderer for the CLI
Expand All @@ -27,7 +28,7 @@ func (r *TerminalRenderer) WeightHistory(weights []model.Weight, config *model.C

// AddWeight renders a success message and the added weight
func (r *TerminalRenderer) AddWeight(weight float64, config *model.Config) (string, error) {
return fmt.Sprintf("Added weight: %s \n", util.WeightUnit(config.UnitSystem, weight)), nil
return fmt.Sprintf("Set weight: %s \n", util.WeightUnit(config.UnitSystem, weight)), nil
}

// Config prints the given configuration with weight, amr and bmr
Expand Down
7 changes: 4 additions & 3 deletions renderer/terminal_test.go
Expand Up @@ -3,11 +3,12 @@ package renderer
import (
"errors"
"fmt"
"testing"
"time"

"github.com/fatih/color"
"github.com/zupzup/calories/model"
"github.com/zupzup/calories/util"
"testing"
"time"
)

func TestTerminalError(t *testing.T) {
Expand Down Expand Up @@ -40,7 +41,7 @@ func TestTerminalWeightHistory(t *testing.T) {
func TestTerminalAddWeight(t *testing.T) {
r := TerminalRenderer{}
res, err := r.AddWeight(85.0, &model.Config{})
expected := "Added weight: 85.0 kg \n"
expected := "Set weight: 85.0 kg \n"
if res != expected || err != nil {
t.Errorf("Error, actual: %v expected: %v", res, expected)
return
Expand Down

0 comments on commit 6545fb5

Please sign in to comment.