2023-12-22 13:20:45 +00:00
|
|
|
package dyn_test
|
2023-10-20 12:56:59 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-12-22 13:20:45 +00:00
|
|
|
"github.com/databricks/cli/libs/dyn"
|
2023-10-20 12:56:59 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLocation(t *testing.T) {
|
2023-12-22 13:20:45 +00:00
|
|
|
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())
|
|
|
|
}
|
2024-03-11 21:59:36 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|