mirror of https://github.com/databricks/cli.git
Add function to check if `config.Value` is valid (#1009)
## Changes Small function broken out from other work in progress.
This commit is contained in:
parent
6187803007
commit
ef97e249ec
|
@ -51,6 +51,10 @@ func (v Value) Location() Location {
|
||||||
return v.l
|
return v.l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v Value) IsValid() bool {
|
||||||
|
return v.k != KindInvalid
|
||||||
|
}
|
||||||
|
|
||||||
func (v Value) AsAny() any {
|
func (v Value) AsAny() any {
|
||||||
switch v.k {
|
switch v.k {
|
||||||
case KindInvalid:
|
case KindInvalid:
|
||||||
|
|
|
@ -35,3 +35,10 @@ func TestValueAsMap(t *testing.T) {
|
||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
assert.Len(t, m, 1)
|
assert.Len(t, m, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestValueIsValid(t *testing.T) {
|
||||||
|
var zeroValue config.Value
|
||||||
|
assert.False(t, zeroValue.IsValid())
|
||||||
|
var intValue = config.NewValue(1, config.Location{})
|
||||||
|
assert.True(t, intValue.IsValid())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue