Ai
1 Star 0 Fork 0

idsutong/gqlgen

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
id_test.go 784 Bytes
一键复制 编辑 原始数据 按行查看 历史
Cooper Filby 提交于 2019-10-17 22:06 +08:00 . Add more tests
package graphql
import (
"math"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMarshalID(t *testing.T) {
tests := []struct {
Name string
Input interface{}
Expected string
ShouldError bool
}{
{
Name: "int64",
Input: int64(12),
Expected: "12",
ShouldError: false,
},
{
Name: "int64 max",
Input: math.MaxInt64,
Expected: "9223372036854775807",
},
{
Name: "int64 min",
Input: math.MinInt64,
Expected: "-9223372036854775808",
},
}
for _, tt := range tests {
t.Run(tt.Name, func(t *testing.T) {
id, err := UnmarshalID(tt.Input)
assert.Equal(t, tt.Expected, id)
if tt.ShouldError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
})
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/idsutong/gqlgen.git
git@gitee.com:idsutong/gqlgen.git
idsutong
gqlgen
gqlgen
master

搜索帮助