loading...

Discussion on: Secrets From Fellow Techies on How to Start A Workout Routine

Collapse
derek profile image
derek

Treat it like TDD.

Because uncle Petey always said...

uncle bo pete

// health_test.go
package health

import (
    "log"
    "testing"
)

func TestStregth(t *testing.T) {
    var previous = 10
    t.Run("it should lift more weight than 'previous'", func(t *testing.T) {
        weight := previous + 20

        ok, err := liftKG(weight)
        if err != nil {
            log.Printf("couldn't lift %d KG", weight)
            t.FailNow()
        }

        if ok {
            log.Printf("lifted %d KG", weight)
        }
    })
}

func TestSpeed(t *testing.T) {
    var previous = 6
    t.Run("it should run faster than 'previous'", func(t *testing.T) {
        speed := previous + 2

        ok, err := runKPH(speed)
        if err != nil {
            log.Printf("couldn't run %d KPH", speed)
            t.FailNow()
        }

        if ok {
            log.Printf("ran %d KPH", speed)
        }
    })
}