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:
parent
3568e7c908
commit
aa98134a1e
1 changed files with 18 additions and 21 deletions
|
|
@ -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
|
||||||
|
}{
|
||||||
|
{"String", "test", 0 },
|
||||||
|
{"Int", 1234, 0 },
|
||||||
|
{"Float", float64(1234), 1234 },
|
||||||
}
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
func TestJsonGetInt64WithInt(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := JsonGetInt64(tt.input); got != tt.want {
|
||||||
n := JsonGetInt64(1234)
|
t.Errorf("JsonGetInt64() = %v, want %v", got, tt.want)
|
||||||
assert.Equal(t, int64(0), n)
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJsonGetInt64WithFloat64(t *testing.T) {
|
|
||||||
|
|
||||||
n := JsonGetInt64(float64(1234))
|
|
||||||
assert.Equal(t, int64(1234), n)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue