1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-07-04 12:03:43 +02:00

src/utils/json_test.go: refactor test functions into a single one.

This commit is contained in:
Henrik Hautakoski 2022-10-21 13:19:34 +02:00
parent 3568e7c908
commit aa98134a1e
No known key found for this signature in database
GPG key ID: 608414D93E862CCD

View file

@ -1,25 +1,22 @@
package utils package utils
import ( import "testing"
"testing"
"github.com/stretchr/testify/assert"
)
func TestJsonGetInt64WithString(t *testing.T) { func TestJsonGetInt64(t *testing.T) {
tests := []struct {
n := JsonGetInt64("test") name string
assert.Equal(t, int64(0), n) input interface{}
} want int64
}{
func TestJsonGetInt64WithInt(t *testing.T) { {"String", "test", 0 },
{"Int", 1234, 0 },
n := JsonGetInt64(1234) {"Float", float64(1234), 1234 },
assert.Equal(t, int64(0), n) }
} for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
func TestJsonGetInt64WithFloat64(t *testing.T) { if got := JsonGetInt64(tt.input); got != tt.want {
t.Errorf("JsonGetInt64() = %v, want %v", got, tt.want)
n := JsonGetInt64(float64(1234)) }
assert.Equal(t, int64(1234), n) })
}
} }