From c857449c0a8b6355ef496f8cc7f4a268f787fecb Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Mon, 7 Oct 2024 13:20:36 -0700 Subject: [PATCH] Adding tests. --- clients/databricks/volume_test.go | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/clients/databricks/volume_test.go b/clients/databricks/volume_test.go index b6a2f2dce..fdb379888 100644 --- a/clients/databricks/volume_test.go +++ b/clients/databricks/volume_test.go @@ -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) + } +}