mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-20 09:56:49 +02:00
src/utils/json_test.go: refactor test functions into a single one.
This commit is contained in:
parent
3568e7c908
commit
aa98134a1e
1 changed files with 18 additions and 21 deletions
|
|
@ -1,25 +1,22 @@
|
|||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
func TestJsonGetInt64WithString(t *testing.T) {
|
||||
|
||||
n := JsonGetInt64("test")
|
||||
assert.Equal(t, int64(0), n)
|
||||
}
|
||||
|
||||
func TestJsonGetInt64WithInt(t *testing.T) {
|
||||
|
||||
n := JsonGetInt64(1234)
|
||||
assert.Equal(t, int64(0), n)
|
||||
}
|
||||
|
||||
func TestJsonGetInt64WithFloat64(t *testing.T) {
|
||||
|
||||
n := JsonGetInt64(float64(1234))
|
||||
assert.Equal(t, int64(1234), n)
|
||||
func TestJsonGetInt64(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input interface{}
|
||||
want int64
|
||||
}{
|
||||
{"String", "test", 0 },
|
||||
{"Int", 1234, 0 },
|
||||
{"Float", float64(1234), 1234 },
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := JsonGetInt64(tt.input); got != tt.want {
|
||||
t.Errorf("JsonGetInt64() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue