cd75858f4a
* api: swap testify for test (acl) * api: swap testify for test (agent) Please enter the commit message for your changes. Lines starting * api: swap testify for test (allocations) * api: swap testify for test (api) * api: swap testify for test (compose) * api: swap testify for test (constraint) * api: swap testify for test (consul) * api: swap testify for test (csi) * api: swap testify for test (evaluations) * api: swap testify for test (event stream) * api: swap testify for test (fs) * api: swap testify for test (ioutil) * api: swap testify for test (jobs) * api: swap testify for test (keyring) * api: swap testify for test (operator_ent) * api: swap testify for test (operator_metrics) * api: swap testify for test (operator) * api: swap testify for test (quota) * api: swap testify for test (resources) * api: swap testify for test (fix operator_metrics) * api: swap testify for test (scaling) * api: swap testify for test (search) * api: swap testify for test (sentinel) * api: swap testify for test (services) * api: swap testify for test (status) * api: swap testify for test (system) * api: swap testify for test (tasks) * api: swap testify for test (utils) * api: swap testify for test (variables) * api: remove dependencies on testify and pretty
54 lines
663 B
Go
54 lines
663 B
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/api/internal/testutil"
|
|
"github.com/shoenig/test/must"
|
|
)
|
|
|
|
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 {
|
|
must.Eq(t, c.expected, formatFloat(c.input, 3))
|
|
}
|
|
}
|
|
|
|
func Test_PointerOf(t *testing.T) {
|
|
s := "hello"
|
|
sPtr := pointerOf(s)
|
|
|
|
must.Eq(t, s, *sPtr)
|
|
|
|
b := "bye"
|
|
sPtr = &b
|
|
must.NotEq(t, s, *sPtr)
|
|
}
|