github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/core/meta/bmd_test.go (about) 1 // Package meta_test: unit tests for the package 2 /* 3 * Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved. 4 */ 5 package meta_test 6 7 import ( 8 "github.com/NVIDIA/aistore/cmn" 9 . "github.com/onsi/ginkgo/v2" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("BMD", func() { 14 Describe("validateBucketName", func() { 15 DescribeTable("should accept bucket name", 16 func(bckName string) { 17 bck := cmn.Bck{Name: bckName} 18 Expect(bck.ValidateName()).NotTo(HaveOccurred()) 19 }, 20 Entry( 21 "regular name bucket", 22 "bucket-1024", 23 ), 24 Entry( 25 "with dots", 26 ".bucket.name", 27 ), 28 Entry( 29 "with '_' and '-'", 30 "bucket_name-1024", 31 ), 32 ) 33 34 DescribeTable("should reject bucket name", 35 func(bckName string) { 36 bck := cmn.Bck{Name: bckName} 37 Expect(bck.ValidateName()).To(HaveOccurred()) 38 }, 39 Entry( 40 "empty bucket", 41 "", 42 ), 43 Entry( 44 "contains '$'", 45 "jhljs$lsf", 46 ), 47 Entry( 48 "contains '/'", 49 "bucket/name", 50 ), 51 Entry( 52 "contains '*'", 53 "bucket$name", 54 ), 55 Entry( 56 "contains space", 57 "space bucket", 58 ), 59 Entry( 60 "contains only dots", 61 "...........", 62 ), 63 Entry( 64 "only space", 65 " ", 66 ), 67 ) 68 }) 69 })