1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-09 09:26:54 +00:00
kyverno/vendor/gotest.tools/assert/cmd/gty-migrate-from-testify/call_test.go
2019-06-03 15:14:06 -07:00

35 lines
697 B
Go

package main
import (
"go/ast"
"go/token"
"testing"
"gotest.tools/assert"
)
func TestCall_String(t *testing.T) {
c := &call{
expr: &ast.CallExpr{Fun: ast.NewIdent("myFunc")},
}
assert.Equal(t, c.String(), "myFunc()")
}
func TestCall_StringWithFileInfo(t *testing.T) {
c := &call{
fileset: token.NewFileSet(),
expr: &ast.CallExpr{
Fun: &ast.Ident{
Name: "myFunc",
NamePos: 17,
}},
}
t.Run("unknown file", func(t *testing.T) {
assert.Equal(t, c.StringWithFileInfo(), "myFunc() at unknown file")
})
t.Run("at position", func(t *testing.T) {
c.fileset.AddFile("source.go", 10, 100)
assert.Equal(t, c.StringWithFileInfo(), "myFunc() at source.go:1")
})
}