@@ -658,7 +658,6 @@ func TestSplitUnixSocketPermissionsBits(t *testing.T) {
658658func TestGetFdByName (t * testing.T ) {
659659 // Save original environment
660660 originalFdNames := os .Getenv ("LISTEN_FDNAMES" )
661- originalFds := os .Getenv ("LISTEN_FDS" )
662661
663662 // Restore environment after test
664663 defer func () {
@@ -667,74 +666,54 @@ func TestGetFdByName(t *testing.T) {
667666 } else {
668667 os .Unsetenv ("LISTEN_FDNAMES" )
669668 }
670- if originalFds != "" {
671- os .Setenv ("LISTEN_FDS" , originalFds )
672- } else {
673- os .Unsetenv ("LISTEN_FDS" )
674- }
675669 }()
676670
677671 tests := []struct {
678672 name string
679673 fdNames string
680- fdCount string
681674 socketName string
682675 expectedFd int
683676 expectError bool
684677 }{
685678 {
686679 name : "simple http socket" ,
687680 fdNames : "http" ,
688- fdCount : "1" ,
689681 socketName : "http" ,
690682 expectedFd : 3 ,
691683 },
692684 {
693685 name : "multiple sockets - first" ,
694686 fdNames : "http:https:dns" ,
695- fdCount : "3" ,
696687 socketName : "http" ,
697688 expectedFd : 3 ,
698689 },
699690 {
700691 name : "multiple sockets - second" ,
701692 fdNames : "http:https:dns" ,
702- fdCount : "3" ,
703693 socketName : "https" ,
704694 expectedFd : 4 ,
705695 },
706696 {
707697 name : "multiple sockets - third" ,
708698 fdNames : "http:https:dns" ,
709- fdCount : "3" ,
710699 socketName : "dns" ,
711700 expectedFd : 5 ,
712701 },
713702 {
714703 name : "socket not found" ,
715704 fdNames : "http:https" ,
716- fdCount : "2" ,
717705 socketName : "missing" ,
718706 expectError : true ,
719707 },
720708 {
721709 name : "empty socket name" ,
722710 fdNames : "http" ,
723- fdCount : "1" ,
724711 socketName : "" ,
725712 expectError : true ,
726713 },
727714 {
728715 name : "missing LISTEN_FDNAMES" ,
729716 fdNames : "" ,
730- fdCount : "1" ,
731- socketName : "http" ,
732- expectError : true ,
733- },
734- {
735- name : "missing LISTEN_FDS" ,
736- fdNames : "http" ,
737- fdCount : "" ,
738717 socketName : "http" ,
739718 expectError : true ,
740719 },
@@ -748,11 +727,6 @@ func TestGetFdByName(t *testing.T) {
748727 } else {
749728 os .Unsetenv ("LISTEN_FDNAMES" )
750729 }
751- if tc .fdCount != "" {
752- os .Setenv ("LISTEN_FDS" , tc .fdCount )
753- } else {
754- os .Unsetenv ("LISTEN_FDS" )
755- }
756730
757731 // Test the function
758732 fd , err := getFdByName (tc .socketName )
@@ -777,23 +751,16 @@ func TestGetFdByName(t *testing.T) {
777751func TestParseNetworkAddressFdName (t * testing.T ) {
778752 // Save and restore environment
779753 originalFdNames := os .Getenv ("LISTEN_FDNAMES" )
780- originalFds := os .Getenv ("LISTEN_FDS" )
781754 defer func () {
782755 if originalFdNames != "" {
783756 os .Setenv ("LISTEN_FDNAMES" , originalFdNames )
784757 } else {
785758 os .Unsetenv ("LISTEN_FDNAMES" )
786759 }
787- if originalFds != "" {
788- os .Setenv ("LISTEN_FDS" , originalFds )
789- } else {
790- os .Unsetenv ("LISTEN_FDS" )
791- }
792760 }()
793761
794762 // Set up test environment
795763 os .Setenv ("LISTEN_FDNAMES" , "http:https:dns" )
796- os .Setenv ("LISTEN_FDS" , "3" )
797764
798765 tests := []struct {
799766 input string
0 commit comments