Hi goamz users (this makes it sound like im addressing a support group for some exotic psychedelic drug)
how do you organize your unit tests and general system tests? a while ago i was working on a system which used s3 but the problem was id have to connect to amazon every time i was testing the service which was cumbersome
so instead of using the s3.S3 type in my code i created a proxy interface that wraps it:
basically it serves as a drop in:
import (
)
then there are two ways to satisfy the S3 interface:
- real S3 s3.WrapS3(goamzs3.New(auth, aws.EUWest))
- or the FS s3.WrapFS("/tmp/foo")
see
https://github.com/hraban/s3iface/blob/master/backend_fs_test.go
you could influence that with a build flag or command line arg
the filesystem wrapper is not perfect but it suited my needs more or less
anyway this all got me thinking am I the only one to want / do something like this or how do other people solve it?
it would be nice if goamz itself made S3 an interface and not a struct with methods that would make creating custom implementations that satisfy the interface ("s3 simulators") much nicer.
by much nicer i mean i wouldnt have to do the drop-in import trick in every file that uses s3 i could just pass my custom implementation as long as it satisfies the official s3 interface.
stay cool
hraban