1 Star 0 Fork 60

amuluze / carbon

forked from golang-module / carbon 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
database_test.go 660 Bytes
一键复制 编辑 原始数据 按行查看 历史
gouguoyin@juzifenqi.com 提交于 2022-04-14 10:40 . optimize unit testing
package carbon
import (
"fmt"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestCarbon_Scan(t *testing.T) {
c := NewCarbon()
err := c.Scan(time.Now())
assert.Nil(t, err)
assert.Equal(t, c.ToDateTimeString(), Now().ToDateTimeString())
}
func TestCarbon_Value(t *testing.T) {
c := Now()
v, err := c.Value()
assert.Nil(t, err)
assert.Equal(t, v, c.time)
}
func TestError_Scan(t *testing.T) {
c, v := NewCarbon(), "xxx"
err := c.Scan(v)
assert.Equal(t, err, fmt.Errorf("can not convert %v to carbon", v))
}
func TestError_Value(t *testing.T) {
c := Parse("")
v, err := c.Value()
assert.Nil(t, err)
assert.Equal(t, v, nil)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/amuluze/carbon.git
git@gitee.com:amuluze/carbon.git
amuluze
carbon
carbon
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891