The cake wasn't really a lie: if the test subjects had survived, they would have received cake. However, what GLADoS's promise was a bit misleading: "In the end, there will be cake." She did not specify those that died would not be receiving the cake.
You get the cake in the end because you...