databricks-cli/libs/dyn/location_test.go

27 lines
574 B
Go
Raw Permalink Normal View History

package dyn_test
2023-10-20 12:56:59 +00:00
import (
"testing"
"github.com/databricks/cli/libs/dyn"
assert "github.com/databricks/cli/libs/dyn/dynassert"
2023-10-20 12:56:59 +00:00
)
func TestLocation(t *testing.T) {
loc := dyn.Location{File: "file", Line: 1, Column: 2}
2023-10-20 12:56:59 +00:00
assert.Equal(t, "file:1:2", loc.String())
}
func TestLocationDirectory(t *testing.T) {
loc := dyn.Location{File: "file", Line: 1, Column: 2}
dir, err := loc.Directory()
assert.NoError(t, err)
assert.Equal(t, ".", dir)
}
func TestLocationDirectoryNoFile(t *testing.T) {
loc := dyn.Location{}
_, err := loc.Directory()
assert.Error(t, err)
}