It fails.
So the common explanation of how a Golem's Magic Immunity works it is effectively has infinite SR, partly because no one actually understands infinite isn't a number, which allows them to ignore SR-checking Spells. And this explanation has a lot of problems with it because a creature with SR can choose to lower it's SR while a creature with Immunity to Magic cannot.
It also, as you point out, causes some confusion with the Beguiler. Magic Immunity is not Spell Resistance and the Golems do not have Spell Resistance. They do no have a number that can be overcome, not even if your Check is "infinite", because they do not have a number to begin with. The Beguiler's ability to overcome a creature's SR simply doesn't apply.
Now Immunity to Magic does render a creature immune to to Spells that check Spell Resistance. Things that bypass the check, such as a Supernatural Ability or a Spell doesn't check SR to begin with, work against a golem just fine. But these effects are not trying to overcome Spell Resistance, rather they because they do not allow Spell Resistance to apply in the first place so they are exempt from the Golem's Immunity. But as noted, the Beguiler's capstone does not alter a Spell's SR Check to yay or nay even through it functionally makes rolling the actual check a little redundant.