@@ -860,62 +860,111 @@ func TestZencoderJobStatus(t *testing.T) {
860860 client : fakeZencoder ,
861861 db : dbRepo ,
862862 }
863- jobStatus , err := prov .JobStatus (& db.Job {
864- ProviderJobID : "1234567890" ,
865- })
866- if err != nil {
867- t .Fatal (err )
868- }
869- resultJSON , err := json .Marshal (jobStatus )
870- if err != nil {
871- t .Fatal (err )
872- }
873- result := make (map [string ]interface {})
874- err = json .Unmarshal (resultJSON , & result )
875- if err != nil {
876- t .Fatal (err )
877- }
878- expected := map [string ]interface {}{
879- "providerName" : "zencoder" ,
880- "providerJobId" : "1234567890" ,
881- "status" : "started" ,
882- "progress" : float64 (10 ),
883- "sourceInfo" : map [string ]interface {}{
884- "duration" : float64 (50000000000 ),
885- "height" : float64 (1080 ),
886- "width" : float64 (1920 ),
887- "videoCodec" : "ProRes422" ,
888- },
889- "providerStatus" : map [string ]interface {}{
890- "sourcefile" : "http://nyt.net/input.mov" ,
891- "created" : "2016-11-05T05:02:57Z" ,
892- "finished" : "2016-11-05T05:02:57Z" ,
893- "updated" : "2016-11-05T05:02:57Z" ,
894- "started" : "2016-11-05T05:02:57Z" ,
863+ var tests = []struct {
864+ ProviderJobID string
865+ Expected map [string ]interface {}
866+ }{
867+ {
868+ "1234567890" ,
869+ map [string ]interface {}{
870+ "providerName" : "zencoder" ,
871+ "providerJobId" : "1234567890" ,
872+ "status" : "started" ,
873+ "progress" : float64 (10 ),
874+ "sourceInfo" : map [string ]interface {}{
875+ "duration" : float64 (50000000000 ),
876+ "height" : float64 (1080 ),
877+ "width" : float64 (1920 ),
878+ "videoCodec" : "ProRes422" ,
879+ },
880+ "providerStatus" : map [string ]interface {}{
881+ "sourcefile" : "http://nyt.net/input.mov" ,
882+ "created" : "2016-11-05T05:02:57Z" ,
883+ "finished" : "2016-11-05T05:02:57Z" ,
884+ "updated" : "2016-11-05T05:02:57Z" ,
885+ "started" : "2016-11-05T05:02:57Z" ,
886+ },
887+ "output" : map [string ]interface {}{
888+ "destination" : "/" ,
889+ "files" : []interface {}{
890+ map [string ]interface {}{
891+ "path" : "s3://mybucket/destination-dir/output1.mp4" ,
892+ "container" : "mp4" ,
893+ "videoCodec" : "h264" ,
894+ "height" : float64 (1080 ),
895+ "width" : float64 (1920 ),
896+ },
897+ map [string ]interface {}{
898+ "height" : float64 (720 ),
899+ "width" : float64 (1080 ),
900+ "path" : "s3://mybucket/destination-dir/output2.webm" ,
901+ "container" : "webm" ,
902+ "videoCodec" : "vp8" ,
903+ },
904+ },
905+ },
906+ },
895907 },
896- "output" : map [string ]interface {}{
897- "destination" : "/" ,
898- "files" : []interface {}{
899- map [string ]interface {}{
900- "path" : "s3://mybucket/destination-dir/output1.mp4" ,
901- "container" : "mp4" ,
902- "videoCodec" : "h264" ,
908+ {
909+ "54321" ,
910+ map [string ]interface {}{
911+ "providerName" : "zencoder" ,
912+ "providerJobId" : "54321" ,
913+ "status" : "finished" ,
914+ "progress" : float64 (100 ),
915+ "sourceInfo" : map [string ]interface {}{
916+ "duration" : float64 (50000000000 ),
903917 "height" : float64 (1080 ),
904918 "width" : float64 (1920 ),
919+ "videoCodec" : "ProRes422" ,
905920 },
906- map [string ]interface {}{
907- "height" : float64 (720 ),
908- "width" : float64 (1080 ),
909- "path" : "s3://mybucket/destination-dir/output2.webm" ,
910- "container" : "webm" ,
911- "videoCodec" : "vp8" ,
921+ "providerStatus" : map [string ]interface {}{
922+ "sourcefile" : "http://nyt.net/input.mov" ,
923+ "created" : "2016-11-05T05:02:57Z" ,
924+ "finished" : "2016-11-05T05:02:57Z" ,
925+ "updated" : "2016-11-05T05:02:57Z" ,
926+ "started" : "2016-11-05T05:02:57Z" ,
927+ },
928+ "output" : map [string ]interface {}{
929+ "destination" : "/" ,
930+ "files" : []interface {}{
931+ map [string ]interface {}{
932+ "path" : "s3://mybucket/destination-dir/output1.mp4" ,
933+ "container" : "mp4" ,
934+ "videoCodec" : "h264" ,
935+ "height" : float64 (1080 ),
936+ "width" : float64 (1920 ),
937+ },
938+ map [string ]interface {}{
939+ "height" : float64 (720 ),
940+ "width" : float64 (1080 ),
941+ "path" : "s3://mybucket/destination-dir/output2.webm" ,
942+ "container" : "webm" ,
943+ "videoCodec" : "vp8" ,
944+ },
945+ },
912946 },
913947 },
914948 },
915949 }
916- if ! reflect .DeepEqual (result , expected ) {
917- pretty .Fdiff (os .Stderr , expected , result )
918- t .Errorf ("Wrong JobStatus returned. Want %#v. Got %#v." , expected , result )
950+ for _ , test := range tests {
951+ jobStatus , err := prov .JobStatus (& db.Job {ProviderJobID : test .ProviderJobID })
952+ if err != nil {
953+ t .Fatal (err )
954+ }
955+ resultJSON , err := json .Marshal (jobStatus )
956+ if err != nil {
957+ t .Fatal (err )
958+ }
959+ result := make (map [string ]interface {})
960+ err = json .Unmarshal (resultJSON , & result )
961+ if err != nil {
962+ t .Fatal (err )
963+ }
964+ if ! reflect .DeepEqual (result , test .Expected ) {
965+ pretty .Fdiff (os .Stderr , test .Expected , result )
966+ t .Errorf ("Wrong JobStatus returned. Want %#v. Got %#v." , test .Expected , result )
967+ }
919968 }
920969}
921970
0 commit comments