You had a solution of Ca2+ salt in the presence of a very hot flame -- that is the definition of a flame test. Most people use cheaper fuel sources, say a natural gas flame, but the impressive thermal energy of burning magnesium is a good way to excite ions to generate their emission spectrum. I often see the magnesium ribbon ash to be white and feathery after burning.