Created
November 28, 2016 13:36
-
-
Save NetguruGist/5f51996bb2690bff1f10910e17b54d19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *Scene) Save(filename string) { | |
f, err := os.Create(filename) | |
if err != nil { | |
panic(err) | |
} | |
defer f.Close() | |
png.Encode(f, s.Img) | |
} | |
func TestSceneSavePanicsWhenFileCannotBePersisted(t *testing.T) { | |
scene := NewScene(4, 4) | |
c := randomColor() | |
scene.EachPixel(func(x, y int) color.RGBA { return c }) | |
assert.Panics(t, func() { | |
scene.Save("/etc/temp.png") | |
}, "panics when the file cannot be persisted") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment