@@ -1413,51 +1413,56 @@ func createDefaultCollectorConfig() *Collector {
14131413
14141414func TestValidateLabel (t * testing.T ) {
14151415 tests := []struct {
1416- name string
1417- input string
1418- wantValid bool
1416+ name string
1417+ input string
1418+ expected bool
14191419 }{
14201420 {
1421- name : "Test 1: Valid label - simple" ,
1422- input : "label123" ,
1423- wantValid : true ,
1421+ name : "Test 1: Valid label - simple" ,
1422+ input : "label123" ,
1423+ expected : true ,
14241424 },
14251425 {
1426- name : "Test 2: Valid label - with dash and underscore" ,
1427- input : "label-123_abc" ,
1428- wantValid : true ,
1426+ name : "Test 2: Valid label - with dash and underscore" ,
1427+ input : "label-123_abc" ,
1428+ expected : true ,
14291429 },
14301430 {
1431- name : "Test 3: Invalid label - too long" ,
1432- input : strings .Repeat ("a" , 257 ),
1433- wantValid : false ,
1431+ name : "Test 3: Invalid label - too long" ,
1432+ input : strings .Repeat ("a" , 257 ),
1433+ expected : false ,
14341434 },
14351435 {
1436- name : "Test 4: Invalid label - special char" ,
1437- input : "label$" ,
1438- wantValid : false ,
1436+ name : "Test 4: Invalid label - special char" ,
1437+ input : "label$" ,
1438+ expected : false ,
14391439 },
14401440 {
1441- name : "Test 5: Invalid label - starts with dash" ,
1442- input : "-label" ,
1443- wantValid : false ,
1441+ name : "Test 5: Invalid label - starts with dash" ,
1442+ input : "-label" ,
1443+ expected : false ,
14441444 },
14451445 {
1446- name : "Test 6: Invalid label - ends with dash" ,
1447- input : "label-" ,
1448- wantValid : false ,
1446+ name : "Test 6: Invalid label - ends with dash" ,
1447+ input : "label-" ,
1448+ expected : false ,
14491449 },
14501450 {
1451- name : "Test 7: Invalid label - empty" ,
1452- input : "" ,
1453- wantValid : false ,
1451+ name : "Test 7: Invalid label - empty" ,
1452+ input : "" ,
1453+ expected : false ,
1454+ },
1455+ {
1456+ name : "Test 8: Invalid label - contains spaces" ,
1457+ input : "label 123" ,
1458+ expected : false ,
14541459 },
14551460 }
14561461
14571462 for _ , tt := range tests {
14581463 t .Run (tt .name , func (t * testing.T ) {
1459- got := validateLabel (tt .input )
1460- assert .Equal (t , tt .wantValid , got )
1464+ actual := validateLabel (tt .input )
1465+ assert .Equal (t , tt .expected , actual )
14611466 })
14621467 }
14631468}
0 commit comments