open-nomad/api/utils_test.go
Seth Hoenig 3943dd1e16 ci: use serial testing for api in CI
This is a followup to running tests in serial in CI.
Since the API package cannot import anything outside of api/,
copy the ci.Parallel function into api/internal/testutil, and
have api tests use that.
2022-03-17 08:35:01 -05:00

42 lines
528 B
Go

package api
import (
"testing"
"github.com/hashicorp/nomad/api/internal/testutil"
"github.com/stretchr/testify/require"
)
func TestFormatRoundedFloat(t *testing.T) {
testutil.Parallel(t)
cases := []struct {
input float64
expected string
}{
{
1323,
"1323",
},
{
10.321,
"10.321",
},
{
100000.31324324,
"100000.313",
},
{
100000.3,
"100000.3",
},
{
0.7654321,
"0.765",
},
}
for _, c := range cases {
require.Equal(t, c.expected, formatFloat(c.input, 3))
}
}