30 lines
554 B
Go
30 lines
554 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFormatDuration(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
seconds int
|
|
expected string
|
|
}{
|
|
{"Nur Sekunden", 45, "0h 0m 45s"},
|
|
{"Genau eine Minute", 60, "0h 1m 0s"},
|
|
{"Stunden und Minuten", 3661, "1h 1m 1s"},
|
|
{"Null Zeit", 0, "0h 0m 0s"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
d := time.Duration(tt.seconds) * time.Second
|
|
result := formatDuration(d)
|
|
assert.Equal(t, tt.expected, result)
|
|
})
|
|
}
|
|
}
|