@@ -51,7 +51,7 @@ type VarcharTestModel struct {
5151 SmallText string `gorm:"size:50"`
5252 MediumText string `gorm:"size:500"`
5353 LargeText string `gorm:"size:4000"`
54- DefaultSizeText string // Should use DefaultStringSize (4000)
54+ DefaultSizeText string
5555 OptionalText * string `gorm:"size:100"`
5656 NotNullText string `gorm:"size:200;not null"`
5757 UniqueText string `gorm:"size:100;uniqueIndex"`
@@ -72,7 +72,6 @@ func setupVarcharTestTables(t *testing.T) {
7272 t .Log ("VARCHAR test tables created successfully" )
7373}
7474
75- // Test 1: Basic CRUD operations with VARCHAR fields of different sizes
7675func TestVarcharBasicCRUD (t * testing.T ) {
7776 setupVarcharTestTables (t )
7877
@@ -142,11 +141,10 @@ func TestVarcharBasicCRUD(t *testing.T) {
142141 }
143142}
144143
145- // Test 2: Edge case - Maximum VARCHAR2 size (4000 bytes) and boundary testing
146144func TestVarcharMaximumSize (t * testing.T ) {
147145 setupVarcharTestTables (t )
148146
149- // Test at exactly 4000 bytes (Oracle VARCHAR2 limit)
147+ // Test at 4000 bytes
150148 text4000 := strings .Repeat ("X" , 4000 )
151149
152150 model := & VarcharTestModel {
@@ -174,7 +172,7 @@ func TestVarcharMaximumSize(t *testing.T) {
174172 t .Error ("4000-byte VARCHAR content mismatch" )
175173 }
176174
177- // Test at boundary: 3999, 4000, 4001 bytes (4001 should work as LargeText is 4000)
175+ // Test at boundary: 3999, 4000, 4001 bytes
178176 testCases := []struct {
179177 name string
180178 size int
@@ -209,8 +207,6 @@ func TestVarcharMaximumSize(t *testing.T) {
209207 }
210208}
211209
212- // This is failing
213- // Test 3: Edge case - NULL values and empty strings
214210func TestVarcharNullAndEmpty (t * testing.T ) {
215211 setupVarcharTestTables (t )
216212
@@ -283,11 +279,10 @@ func TestVarcharNullAndEmpty(t *testing.T) {
283279 }
284280}
285281
286- // Test 4: Negative test - Exceeding VARCHAR size limit
287282func TestVarcharSizeExceeded (t * testing.T ) {
288283 setupVarcharTestTables (t )
289284
290- // Try to insert text larger than SmallText limit (50)
285+ // insert text larger than SmallText limit (50)
291286 tooLargeForSmall := strings .Repeat ("X" , 100 ) // 100 chars, but limit is 50
292287
293288 model := & VarcharTestModel {
@@ -298,7 +293,6 @@ func TestVarcharSizeExceeded(t *testing.T) {
298293
299294 err := DB .Create (model ).Error
300295 if err == nil {
301- // Oracle may truncate or allow it, check what actually got stored
302296 var retrieved VarcharTestModel
303297 DB .First (& retrieved , model .ID )
304298 if len (retrieved .SmallText ) > 50 {
@@ -328,7 +322,6 @@ func TestVarcharSizeExceeded(t *testing.T) {
328322 }
329323}
330324
331- // Test 5: Edge case - Special characters, Unicode, and whitespace
332325func TestVarcharSpecialCharacters (t * testing.T ) {
333326 setupVarcharTestTables (t )
334327
@@ -371,11 +364,10 @@ func TestVarcharSpecialCharacters(t *testing.T) {
371364 }
372365}
373366
374- // Test 6: Edge case - Bulk operations and unique constraints
375367func TestVarcharBulkAndConstraints (t * testing.T ) {
376368 setupVarcharTestTables (t )
377369
378- // Test bulk insert with multiple records
370+ // bulk insert with multiple records
379371 records := []VarcharTestModel {
380372 {SmallText : "Bulk 1" , NotNullText : "Required 1" , UniqueText : "bulk_unique_001" },
381373 {SmallText : "Bulk 2" , NotNullText : "Required 2" , UniqueText : "bulk_unique_002" },
@@ -389,14 +381,14 @@ func TestVarcharBulkAndConstraints(t *testing.T) {
389381 t .Fatalf ("Failed to bulk create records: %v" , err )
390382 }
391383
392- // Verify all records were created
384+ // Verify all records
393385 var count int64
394386 DB .Model (& VarcharTestModel {}).Count (& count )
395387 if count < 5 {
396388 t .Errorf ("Expected at least 5 records, got %d" , count )
397389 }
398390
399- // Test unique constraint violation
391+ // unique constraint violation
400392 duplicateModel := & VarcharTestModel {
401393 SmallText : "Duplicate test" ,
402394 NotNullText : "Required" ,
0 commit comments