Skip to content

Commit

Permalink
Adding tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 7, 2024
1 parent dc3d4db commit c857449
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions clients/databricks/volume_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
package databricks

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestNewVolume(t *testing.T) {
{
// Invalid
{
// Missing name
_, err := NewVolume(map[string]any{"path": "path"})
assert.ErrorContains(t, err, "volume name is missing")
}
{
// Name isn't string
_, err := NewVolume(map[string]any{"name": 1, "path": "path"})
assert.ErrorContains(t, err, "volume name is not a string")
}
{
// Missing path
_, err := NewVolume(map[string]any{"name": "name"})
assert.ErrorContains(t, err, "volume path is missing")
}
{
// Path isn't string
_, err := NewVolume(map[string]any{"name": "name", "path": 1})
assert.ErrorContains(t, err, "volume path is not a string")
}
}
{
// Valid
volume, err := NewVolume(map[string]any{"name": "name", "path": "path"})
assert.Nil(t, err)
assert.Equal(t, "name", volume.name)
assert.Equal(t, "path", volume.path)
}
}

0 comments on commit c857449

Please sign in to comment.