Validation: Move validation into apimachinery package (#111736)
This commit is contained in:
@@ -3,6 +3,7 @@ package apistore
|
||||
import (
|
||||
"context"
|
||||
"math/rand/v2"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -35,6 +36,7 @@ func TestPrepareObjectForStorage(t *testing.T) {
|
||||
opts: StorageOptions{
|
||||
EnableFolderSupport: true,
|
||||
LargeObjectSupport: nil,
|
||||
MaximumNameLength: 100,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -49,10 +51,18 @@ func TestPrepareObjectForStorage(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Error on missing name", func(t *testing.T) {
|
||||
dashboard := dashv1.Dashboard{}
|
||||
_, err := s.prepareObjectForStorage(ctx, dashboard.DeepCopyObject())
|
||||
dashboard := &dashv1.Dashboard{}
|
||||
_, err := s.prepareObjectForStorage(ctx, dashboard)
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "missing name")
|
||||
require.ErrorContains(t, err, "missing name")
|
||||
})
|
||||
|
||||
t.Run("name is too long", func(t *testing.T) {
|
||||
dashboard := &dashv1.Dashboard{}
|
||||
dashboard.Name = strings.Repeat("a", 120)
|
||||
_, err := s.prepareObjectForStorage(ctx, dashboard)
|
||||
require.Error(t, err)
|
||||
require.ErrorContains(t, err, "name exceeds maximum length")
|
||||
})
|
||||
|
||||
t.Run("Error on non-empty resource version", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user