open-nomad/client/structs/csi_test.go
hc-github-team-nomad-core a2f56797a0
backport of commit 4895d708b438b42e52fd54a128f9ec4cb6d72277 (#18531)
Co-authored-by: Daniel Bennett <dbennett@hashicorp.com>
2023-09-18 14:29:29 -05:00

46 lines
979 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package structs
import (
"testing"
"github.com/shoenig/test/must"
"github.com/hashicorp/nomad/nomad/structs"
)
func TestClientCSINodeExpandVolumeRequest_Validate(t *testing.T) {
req := &ClientCSINodeExpandVolumeRequest{
PluginID: "plug-id",
VolumeID: "vol-id",
ExternalID: "ext-id",
Claim: &structs.CSIVolumeClaim{
AllocationID: "alloc-id",
},
}
err := req.Validate()
must.NoError(t, err)
req.PluginID = ""
err = req.Validate()
must.ErrorContains(t, err, "PluginID is required")
req.VolumeID = ""
err = req.Validate()
must.ErrorContains(t, err, "VolumeID is required")
req.ExternalID = ""
err = req.Validate()
must.ErrorContains(t, err, "ExternalID is required")
req.Claim.AllocationID = ""
err = req.Validate()
must.ErrorContains(t, err, "Claim.AllocationID is required")
req.Claim = nil
err = req.Validate()
must.ErrorContains(t, err, "Claim is required")
}