3943dd1e16
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.
42 lines
528 B
Go
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))
|
|
}
|
|
}
|